[GIS] gdal2tiles.py generates wrong tiles / MapTiler the right ones

gdalgdal2tilesleaflettilesweb-mapping

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?

Best Answer

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});