Export mbtiles at different zoom levels for different areas
Hi,
I am producing a detailed map of a region of northern Peru up to zoom level 14. I want to include tiles for the whole of Latin America to give an overview, but I do not need tiles outside my focus area at a zoom of more than level 7. If I do the whole region at zoom 14 the mbtiles file is huge! Is there any way to do two exports with different boundaries and zoom ranges and combine them after into one mbtiles file?
Gregor
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Will White on 12 Sep, 2011 03:42 PM
Hi Gregor,
We have an issue open about supporting this in mbutil: https://github.com/mapbox/mbutil/issues/8
I did find this little command line trick, which might be worth a try: https://gist.github.com/836634
Will
3 Posted by gregor on 12 Sep, 2011 04:32 PM
Thanks for the link Will. I don't quite understand what this command is doing (UNIX pipes still confuse me). Is it taking the two mbtiles files and outputting them to a new file .dump? I guess there would need to be no overlap for this to work?
4 Posted by gregor on 21 Sep, 2011 07:14 AM
To follow up on this: https://gist.github.com/836634 does work, but there is a risk of repeated ids, especially if both mbtiles have an interactive layer, and the two mbtiles cannot overlap.
echo 'dump' | sqlite3 tilesA.mbtiles | sqlite3 tilesB.mbtilesThis command will merge tilesA.mdtiles into tilesB.mbtiles by basically dumping the entire tilesA database to a SQL text file, and feed that into tilesB.
You don't need to worry about errors like
table X already existsorindex X already existssince it is just trying to create tables that already exist in the destination mbtiles. But you do need to worry about errors likecolumn X is no uniquesince this signifies there is a conflict somewhere. You can check what is throwing the error by outputting the SQL from tilesA.mbtiles to a text file and inspecting it:echo '.dump' | tilesA.mbtiles >sqldump.txt5 Posted by gregor on 21 Sep, 2011 05:26 PM
Maybe someone from Mapbox can clarify this: looking through the code for node-mbtiles it looks like tile_id is created as a hash from image data, therefore any conflict of ids when merging two mbtiles is because the image is the same (I imagine plain all one color tiles) so that this conflict would not be something to worry about. Is that correct?
Support Staff 6 Posted by Will White on 22 Sep, 2011 04:06 PM
Yep, that is correct regarding the ID assignment strategy. It is an md5 hash of the tile data. But merging isn't very well tested, so please test your outputted map carefully!
Thanks,
Will
gregor closed this discussion on 23 Sep, 2011 10:07 PM.