6

I'm trying to generate tiles with gdal2tiles.py and the resulting tiles are stored as 18/132639/164219. If I do the same thing with MapTiler (the GUI variant of gdal2tiles) the tile result is 18/132639/97923. I want the results from MapTiler (97923), but just with gdal2tiles, as I want to do this in a batch process and not with a GUI.

I tried a lot of things already, warping, translating, whatever, and it's getting very annoying, especially as it says that MapTiler is just a graphical interface for gdal2tiles and does basically the same.

gdal2tiles.py -z 17-19 -s EPSG:900913 -p raster overlay-level1.png
gdal2tiles.py -z 17-20 -s EPSG:3785 overlay-level1.png
gdal2tiles.py -p geodetic -s EPSG:4326 -z 18-21 -w none overlay-level1.png

Most of those result in an ERROR 5 Access window out of range in RasterIO() or ERROR 5: Illegal values for buffer size.

This one works, but results in the wrong Y values:

gdal2tiles.py -s EPSG:4326 -z 16-19 -w none overlay-level1.png

Any ideas what's wrong there?

  • I tried to produce tiles to publish my map online. Want to get same structure as produce last version 0.5.2 of maptiler but want do that using gdal script. I have tested - last maptiler to compare how should it looks like - old version of maptiler - gdal2tiles.py 25611 2013-02-07 10:24:56Z bishop $ (from qgis valmiera package) - gdal2tiles.py 19288 2010-04-02 18:36:17Z rouault $ + your (Andre Joost) modification http://gis.stackexchange.com/questions/63024/gdal2tiles-maptiles-from-bsb-kap-are-switched – user27845 Mar 9 '14 at 11:29
11

The solution is much simpler than expected. Just turn TMS settings to true in Leaflet.

L.tileLayer('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {tms: true});
  • Note that gdal2 gdal2tiles.py (GDAL 2.1.3, released 2017/20/01) uses the "correct" or Google/OSM convention for x vs y, so tiles generated may not need such fixes. – Ahmed Fasih Nov 27 '17 at 21:32
  • @AhmedFasih, It still not works. tested from GDAL 2.3.1 – Jane Jul 16 '18 at 13:00
4

gdal2tiles uses the TMS specification for tile naming (bottom to top), while Maptiler allows you to use the Google/Openstreetmap tile naming system (top to bottom).

See my answer to this topic on how to modify gdal2tiles.py for Google/OSM tile naming:

GDAL2Tiles: MapTiles from BSB/KAP are Switched

  • I made the changes, but the Y-numbers remain the same? I'm working with CRC EPSG:4326, which is probably also an issue, as leaflet requires EPSG:3857. – user20442 Jul 25 '13 at 15:26
  • You should have replaced ty and y by ty2 and y2 in the quoted existing lines as well. My source and tiles were all in EPSG:3857. – AndreJ Jul 25 '13 at 16:58
  • Oh ok. Well, since I don't want to change gdal2tiles.py on all involved machines, the tms: true variant is the better solution. Thanks! – user20442 Jul 25 '13 at 17:09
-1

You can download the updated gdal2tiles.py for Google/OSM tiles by link

http://gisfile.com/user/admin/gdal2tiles.py

  • Welcome to GIS@SE, thanks for your answer, however you should explain in your answer what the difference is in your recommended download link as compared to the original question, so that future users will understand as well. best Regards – Mark Cupitt Oct 22 '14 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy