0

I'm looking for a raster file that has all quadkeys of Bing Maps for a given zoom level. Does that exist? If not, how could I create it myself in R?

I have spatial data as a set of shapefiles (none of which covers all tiles of the globe) for the whole world with a resolution of about 600m x 600m per pixel/geometry (equivalent to zoom level 16) and would like to extract that data for all countries in the world (which I also have as a shapefile). Since the quadkeys are unique the easiest way would be to get for each country the list of quadkeys that belong to it and then to use that to merge it with the shapefiles (that I can convert to simple data.frames, thus avoiding spatial operations).

I tried using the function "st_intersection" to combine the two shapefiles, but that crashes R for many cases. I also tried to combine the different shapefiles first, creating a "complete" one, but that also crashes R.

If I could create a raster file with all quadkeys, I could simply stack this with the rasterised country codes and convert both to a data.frame and I would be done with the spatial operations. Unfortunately I couldn't find a raster, nor an explanation on how I would create it myself.

1 Answer 1

0

Quadkeys are a mathematical model, so you can calculate every possible quadkey for a specific zoom level. That said, you likely will run into issues when you get to higher zoom levels like 19, which has 274,877,906,944 quadkeys. A better approach is to calculate the quadkeys that your image/data covers using math. The math algorithms for Bing Maps tiles is well documented here: https://learn.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system

Using that math, you can take the top left and bottom right corners of the bounding box of your data/image, then calculate the tile XY position using the LatLongToPixelXY and PixelXYToTileXY methods. You can then loop from the left to right on X, and top to bottom on y and get all the xy combos inbetween then use the TileXYToQuadKey method to get the individual quadkeys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.