Created
October 3, 2012 23:09
-
-
Save zhm/3830471 to your computer and use it in GitHub Desktop.
Delete zoom levels from an MBTiles file (set max zoom)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- change 18 to whatever the max zoom level you want in your MBTiles | |
DELETE FROM images WHERE | |
tile_id IN (SELECT tile_id FROM map WHERE zoom_level > 18) AND | |
tile_id NOT IN (SELECT tile_id FROM map WHERE zoom_level <= 18); | |
DELETE FROM map WHERE zoom_level > 18; | |
UPDATE metadata SET value = '18' WHERE name = 'maxzoom'; | |
-- now run the VACUUM command |
I'm doing this on a raster MBtiles which doesn't have an "images" table. If you're in the same situation, replace the first two statements with this:
DELETE FROM tiles WHERE zoom_level > 18;
DELETE FROM tiles_data WHERE
tile_data_id IN (SELECT tile_data_id FROM tiles_shallow WHERE zoom_level > 9) AND
tile_data_id NOT IN (SELECT tile_data_id FROM tiles_shallow WHERE zoom_level <= 9);
DELETE FROM tiles_shallow WHERE zoom_level > 9;
UPDATE metadata SET value = '9' WHERE name = 'maxzoom';
VACUUM;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I'm badly in need to change max. zoom level of my *.mbtiles file. Can you please help how to use these codes. I'm completely new in GistBox. I'm not sure where and how to use these codes. Please help me. Any help will make me grateful to you.
Regards,
Siddique