I have 3 rasters, each is in the same SRS but with differing extents

I want to combine them into a single tile set using gdal2tiles.py


gdal2tiles.py -z '2-4' -e -p raster -r average --s_srs EPSG:27700 raster1.tif /tiles
gdal2tiles.py -z '5-8' -e -p raster -r average --s_srs EPSG:27700 raster2.tif /tiles
gdal2tiles.py -z '9-12' -e -p raster -r average --s_srs EPSG:27700 raster3.tif /tiles

When I try this the tiles are not centred correctly when zooming from 4 to 5 and then 8 to 9. I suspect this is due to inconsistent extents of the rasters. Or am I missing something else? Should I be wrapping them in a virtual raster


See my similar but not identical question at GDAL create mbtiles with differing image by zoom level about merging different rasters at specified zoom levels, but using gdal_translate and gdaladdo rather than gdal2tiles.

I would suggest you take the raster with the broadest extent and merge the smaller ones into it (i.e. make the broadest one the file called main.mbtiles in the answer provided there).

By the way, be aware that mbtiles viewer behaviour may be inconsistent if you are trying to display an area that is in some levels but not others. Depending on how you've set the extent metadata (which is what the merge above tries to do), and how the viewer responds to not finding a tile it requests, you may get blanks or a scaled version of a tile at a zoom level that does exist.


Came here looking for the same thing. I'm trying an alternative approach of merging the multiple .tif files into one. Check out: Merging tif images into a single GeoTiff with QGIS

  • A VRT would probably be the easiest, not the fastest way. Aug 2 '19 at 11:13
  • @bugmenot123 pls expand 'VRT' and share a link if possible?
    – Nikhil VJ
    Aug 3 '19 at 7:03

Your Answer

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

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