2

I have several .mbtiles with no (or little) overlapping areas and I would like to merge them into one file in order to be able to serve them more easily.

I'm looking for a command line tool that can do this.

tile-join seems to work only on vector tiles. When I run to on my raster tiles it crashes:

tile-join first.mbtiles second .mbtiles -o combined.mbtiles
libc++abi.dylib: libc++abi.dylib: libc++abi.dylib: libc++abi.dylib: libc++abi.dylib: terminating with uncaught exception of type protozero::unknown_pbf_wire_type_exception: unknown pbf field type exceptionterminating with uncaught exception of type protozero::unknown_pbf_wire_type_exception: unknown pbf field type exceptionterminating with uncaught exception of type protozero::unknown_pbf_wire_type_exception: unknown pbf field type exceptionlibc++abi.dylib: terminating with uncaught exception of type protozero::unknown_pbf_wire_type_exception: unknown pbf field type exceptionlibc++abi.dylib: terminating with uncaught exception of type protozero::unknown_pbf_wire_type_exception: unknown pbf field type exception
Abort trap: 6

gdal_merge.py works on .tiff files but I have .mbtiles as input.

Update:

I managed to convert the .mbtiles to .tiff using

gdal_translate input.mbtiles output.tiff
gdal_translate input2.mbtiles output2.tiff

Then merge them using

gdal_merge.py -co COMPRESS=LZW  *.tiff

This gives me one out.tiff but then how to get a .mbtiles back? goal_translate gives me this error:

gdal_translate -of mbtiles out.tif  out.mbtiles
Input file size is 81920, 81920
0ERROR 6: GDALDriver::Create() ... no create method implemented for this format.

any ideas?

1
  • 1
    gdal_translate -of MBTILES merged.tif output.mbtiles -co ZOOM_LEVEL_STRATEGY=AUTO should be working starting with gdal version >= 2.1 (though i tested it with gdal 2.3.0) Furthermore you should add some overviews to the file with gdaladdo -r average output.mbtiles 2 4 8 16
    – Valentin
    Jun 22, 2018 at 19:38

2 Answers 2

1

You can use SQLITE 3 command line tool or OGRINFO SQLITE Functions you need to connect to first database and then attach second database and insert into tiles * from others.tiles

Make sure you vacuum database and Re index tables

https://sqlite.org/cli.html https://www.sqlite.org/lang_attach.html

Do it from command line or from a SQLITE EDITOR DBBROWSER is free

5
0

Extending GeospatialInformationTech's answer, the mbutil patch tool from https://github.com/mapbox/mbutil/blob/d495c0a737f4bce5fde8e707fe267674be39369a/patch can merge raster mbtiles where there are no overlapping tiles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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