Export mbtiles at different zoom levels for different areas

gregor's Avatar

gregor

12 Sep, 2011 03:28 PM

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

  1. Support Staff 2 Posted by Will White on 12 Sep, 2011 03:42 PM

    Will White's Avatar

    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

  2. 3 Posted by gregor on 12 Sep, 2011 04:32 PM

    gregor's Avatar

    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?

  3. 4 Posted by gregor on 21 Sep, 2011 07:14 AM

    gregor's Avatar

    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.mbtiles

    This 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 exists or index X already exists since it is just trying to create tables that already exist in the destination mbtiles. But you do need to worry about errors like column X is no unique since 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.txt

  4. 5 Posted by gregor on 21 Sep, 2011 05:26 PM

    gregor's Avatar

    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?

  5. Support Staff 6 Posted by Will White on 22 Sep, 2011 04:06 PM

    Will White's Avatar

    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

  6. gregor closed this discussion on 23 Sep, 2011 10:07 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

21 May, 2013 02:18 PM
09 Apr, 2013 01:55 PM
21 May, 2013 12:03 PM
21 May, 2013 11:36 AM
21 May, 2013 08:26 AM

 

21 May, 2013 09:53 AM
21 May, 2013 09:30 AM