[GIS] Joining several raster .mbtiles

mbtiles

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?

Best Answer

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

Related Question