Last active
February 11, 2026 06:42
-
Star
(136)
You must be signed in to star a gist -
Fork
(25)
You must be signed in to fork a gist
-
-
Save tmcw/4954720 to your computer and use it in GitHub Desktop.
Revisions
-
tmcw revised this gist
Feb 15, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ ending in `/0/0/0.png` or something. Sometimes if it's a script, it'll look like Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps. Most of those are in XYZ. The best documentation for that is [slippy map tilenames](http://wiki.openstreetmap.org/wiki/slippy_map_tilenames) on the OSM Wiki, and Klokan's [Tiles a la Google](http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/). Some of them are in TMS instead. TMS is an OSGeo spec. [Here's the wiki page on it](http://en.wikipedia.org/wiki/Tile_Map_Service). It's less popular and few services support the whole spec. -
tmcw revised this gist
Feb 15, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ Let's get to the point. The only difference between the two is a flipped y coord In math: y = (2^z) - y - 1 javascript @@ -35,13 +35,13 @@ y = pow(2, z) - y - 1; python ```php y = (2 ** z) - y - 1 ``` ruby ```ruby y = (2 ** z) - y - 1 ``` ### Addendum -
tmcw revised this gist
Feb 14, 2013 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,4 +46,6 @@ y = (2 ** z) - y - 1; ### Addendum When I say 'no difference' or 'no advantage' I mean for most maps. If you have some weird projection, use TMS but ideally don't make a tiled map in a weird projection in the first place. If you're forced to use OSGeo standards, do that but try to find a different job. This originally credited OGC with TMS. It was OSGeo. OGC has WMTS. Don't use that either. -
tmcw revised this gist
Feb 14, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of map Most of those are in XYZ. The best documentation for that is [slippy map tilenames](http://wiki.openstreetmap.org/wiki/slippy_map_tilenames) on the OSM Wiki. Some of them are in TMS instead. TMS is an OSGeo spec. [Here's the wiki page on it](http://en.wikipedia.org/wiki/Tile_Map_Service). It's less popular and few services support the whole spec. There are no advantages of XYZ over TMS or vice-versa for most maps*, but XYZ is more popular. @@ -46,4 +46,4 @@ y = (2 ** z) - y - 1; ### Addendum When I say 'no difference' or 'no advantage' I mean for most maps. If you have some weird projection, use TMS but ideally don't make a tiled map in a weird projection in the first place. If you're forced to use OSGeo standards, do that but try to find a different job. -
tmcw created this gist
Feb 14, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ The difference between XYZ and TMS tiles and how to convert between them Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in `/0/0/0.png` or something. Sometimes if it's a script, it'll look like `&z=0&y=0&x=0` instead. Anyway, these are usually maps in Spherical Mercator. Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps. Most of those are in XYZ. The best documentation for that is [slippy map tilenames](http://wiki.openstreetmap.org/wiki/slippy_map_tilenames) on the OSM Wiki. Some of them are in TMS instead. TMS is an OGC spec. [Here's the wiki page on it](http://en.wikipedia.org/wiki/Tile_Map_Service). It's less popular and few services support the whole spec. There are no advantages of XYZ over TMS or vice-versa for most maps*, but XYZ is more popular. ## Converting Let's get to the point. The only difference between the two is a flipped y coordinate. In math: y = (2^z) - y - 1; javascript ```javascript y = Math.pow(2, z) - y - 1; ``` php ```php y = pow(2, z) - y - 1; ``` python ```php y = (2 ** z) - y - 1; ``` ruby ```ruby y = (2 ** z) - y - 1; ``` ### Addendum When I say 'no difference' or 'no advantage' I mean for most maps. If you have some weird projection, use TMS but ideally don't make a tiled map in a weird projection in the first place. If you're forced to use OGC standards, do that but try to find a different job.