I'm trying to georeference a set of image tiles downloaded from a Google Maps site. Based only on each image's Google Maps grid reference and zoom level, how can I calculate the real-world coordinates?
The page at http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection shows the coordinates and Google Maps grid reference for web mercator tiles.
For example, the centre tile is x=49, y=30, z=6
and has the corner coordinates 10644926.307106785, 626172.1357121654, 11271098.44281895, 1252344.27142432
:
Is it possible to calculate the corner coordinates based solely on the grid reference and zoom level (49, 30, 6)?
This is similar to How to georeference a web mercator tile correctly using gdal? but I need a completely programmatic solution, without needing to look anything up online. (Or, if I do need to look up values online it needs to be programmatic).
Edit: this screenshot shows the location of a sample tile (zoom level 11, x = 1593, y = 933). How would I georeference that tile?
Best Answer
This page http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection provides algorithms, written in python, to compute tile bounds in EPSG:900913 coordinates and in latutude/longitude using WGS84 datum.
The class
GlobalMercator
in this script http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/globalmaptiles.py contains two methods,TileBounds()
andTileLatLonBounds()
to do this.A modified version of the script to show tile bounds coordinates:
Usage:
tilebounds xTile yTile zoom
.For example, the output for the tile
x=49
,y=30
,z=6
is as follows:A tile can be downloaded with the url
http://mt.google.com/vt?x=xTile&y=yTile&z=zoom
, but this is forbidden to access it directly.The software was originally written by Klokan Petr Přidal.
I hope this could help!