Export latitude & longitude zoom 18 vector tiles filtered by roads as csv - maps

I want to create a database of level 18 vector tiles and filter them by any type of road/transportation data.
For example:
(tile_x-tile_y-zoomlevel)
138139-86686-18 (road)
138140-86687-18 (no road -> skip)
138140-86686-18 (road)
...
CSV would look like:
138139,86686
138140,86686
I have downloaded a old planet vector map in mbtiles format, max zoom level is 14.
Now i need to slice this map into zoom level 18 tiles and loop through each tile if it contains road data.
What i have tried:
1: I have learned a bit of Python and tried to create a plugin in QGIS but i dont know how to start doing the map stuff, i cannot find any help.
2: I have set up a virtual machine running ubuntu server and try to use tilemaker
How can i slice the map to zoom 18 tiles, filter it by road data and export the result?

Related

How can I place 2D .tif images in a z-stack using numpy and matplotlib?

I have microscopy data in a .tif file that I can view in ImageJ. This tif file contains slices in the z plane that are 2 microns apart. ImageJ has the functionality to produce a stack of these images and allow the user to scroll through the z plane. the user can also rotate the image and peer through the slices - imagine looking at sheets of paper on a table, and going eye level so you see all the sheets stacked onto each other. This is what I am trying to reproduce in Python.
There are 15 different slices in this .tif file. I have so far managed to create an np array these slices. The shape of my array is currently (1024,1024,15). I have then tried to use np.concatenate and set axis to 2.:
x = np.concatenate([images_array[i] for i in range(15)], axis=2)
However, the error message thrown is 'axis 2 is out of bounds for array of dimension 2'. The problem i"m running into is that from np.shape(), it seems like I have a 3D array, so why can't I stack it?
Thanks

How to create a grid of 50sq km Rectangles or Hexagons in React Map GL(Mapbox) and Deck.gl, that covers an entire country

I'm trying to create a Grid Layer of Either Rectangles or Hexagons in React Map GL(Map Box) and Deck GL, that cover an entire country.
This is what I'm trying to achieve: http://webcoveragemap.rootmetrics.com/en-US
These are the Solutions I've found:
https://deck.gl/#/documentation/deckgl-api-reference/layers/s2-layer
https://deck.gl/#/documentation/deckgl-api-reference/layers/h3-cluster-layer
The problem I'm facing with is that s2-layer uses S2 Cell token (Which I can't seem to understand how to calculate and similarly h3-cluster-layer uses H3 and for that too I can't find any code samples for React. So can anybody explain me either how to use H3, S2 and calculate 50sq km boxes that can be viewed on React Map Gl with Deck GL (if needed). Or suggest another Solution?
Turns out there's java script version of H3-Core Library (A hexagon-based geographic grid system). https://www.npmjs.com/package/h3-js
All it require's to convert a lat/lng point to a hexagon index at some resolution is following code:
const h3Index = h3.geoToH3(37.3615593, -122.0553238, 7);
// -> '87283472bffffff'

Big SCNGeometry SceneKit for iOS

I am working on a cocoa/iOS projet.
I have a common swift class which manage a Scenekit scene.
I want to draw a big terrain (about 5000x5000 points).
I have 2 triangles per 4 points. I have created a scngeometry object for the whole terrain (is it a good thing ?)
I decided to store those points in a 6-Float structure (x,y,z and r,g,b). I tried to create an empty array or to allocate a big array at the begining : i got the same issue.
I work with Int datatype for indices array.
The project works fine on Cocoa but i get memory errors on iOS. I think this is because of the need to have a big and contigous array for vertex.
I tried to create several chunks of geometry objects but scene kit does not like if we erase a previous buffer.
What is the best practice in this case ?
Is there a way to store vertex on the mass storage instead of memory arrays/buffers ?
Thanks
So...twice as many terrain points as there are pixels on a shiny new 5K display? That's a huge amount of memory to be using at once on iOS. And you won't be able to see that resolution on an iOS device.
So how about:
Break your 25 million pixel terrain into smaller tiles, each in its own SCNNode. Loop through the tiles, create one SCNNode, throw away the 6-Float array for that tile and move to the next.
Use SCNLevelOfDetail to produce much simpler versions of those nodes, for display when they're very far away.
Do the construction work on OS X. Archive your scene (NSSecureCoding). Bundle that scene into the iOS app.
Consider using reference nodes in your main SCNScene, and archive each tile as a separate SCNScene file.
Hopefully you're already using triangle strips, not triangles, to build your geometry.

Leaflet JS: Custom 2D projection that uses meters instead of lat,long

I am working on a custom game map. This map is basically a raster image, overlayed with some paths and markers. I want to use Leaflet to display the map.
What I am struggling with, is that Leaflet uses Latitude and Longitude to calculate positions, while it uses meters for distances (path lengths, radii of circles, etc).
This is very understandable when dealing with a spherical world like our Earth, but it complicates the custom map, which is flat a lot.
I would like to be able to specify the positions in the same unit as the distances.
Now, by default Leaflet uses a Spherical Mercator projection. According to the Docs, it is possible to define your own projections and coordinate reference systems, but I have been unable to do this thus far.
How would this be possible? Or is there a simpler way?
You should take a look at the simple coordinate reference system (L.CRS.Simple) included with Leaflet:
A simple CRS that maps longitude and latitude into x and y directly. May be used for maps of flat surfaces (e.g. game maps).
You can define the CRS of your L.Map instead upon initialization like so:
new L.Map('myDiv', {
crs: L.CRS.Simple
});
Some further elaboration: As #ghybs pointed out in the comment below and the comment to your question the default sperical mercator projection (L.CRS.EPSG3857) already works in meters. When you calculate the distance between two coordinates, Leaflet returns meters, example:
var startCoordinate = new L.LatLng(0, -1);
var endCoordinate = new L.LatLng(0, 1);
var distance = startCoordinate.distanceTo(endCoordinate);
console.log(distance);
The above will print 222638.98158654713 to your console which is the distance between those two coordinates in meters. Problem is that when using spherical projection, distance between two coordinates will become less the further you get from the equator which will become problematic when creating a flat gameworld. That's why you should use L.CRS.Simple, you won't have said problem.

Find layers in current map view with Leafletjs

I have an app that displays recent jobs on a map as pinpoints using Leafletjs.
With Leafletjs, when you want to zoom to the user's detected location, you call something like:
map.locate({'setView' : true, 'timeout' : 10000, maxZoom: 10});
However, for some locations, the zoom level 10 does not contain any job points, so I'd like to dynamically set the zoom so that at least on job is visible to the users.
I know that I can listen for the locate function's success and then check with something like:
map.on('locationfound', function() {
//for marker in markers{
//is point within currently visible bounds
//break on first positive
//else,
//zoom up a level, repeat previous checks
}
}
but that's quite inefficient, especially if I have a large number of points.
Does Leaflet have any built in functions/methods to provide information about layers within the current map view?
If you do some things on the server side, you can probably do the calculations fast enough.
Store the locations in pixel coordinates in your database at some way-zoomed-in zoom level (I use zoom level 23). I call this coordinate system "Vast Coordinate System". Then, to get the tile coordinates for a point at a specific location is IIRC one bitwise shift -- very fast, and something you can do in SQL.
Convert your users' location to pixel coords at that way-zoomed in level.
Iterate on zoom level. Get the tile coord for the user's location at that zoom level, then do an SQL query which counts the number of points on that tile. If > 0, stop.
Your SQL will be something like (sorry, I'm being lazy and doing it from memory/thinking instead of actually trying it out)
SELECT count(*) WHERE (vcsX>>(zoom+8)==userX>>(zoom+8)) AND (vcsY>>(zoom+8)==userY>>(zoom+8));
where vcsX and vcsY are the pixel coordinates in Vast Coordinate System.

Resources