Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save moneytoo/eb8120bf572c37adc894a478463376dd to your computer and use it in GitHub Desktop.
Save moneytoo/eb8120bf572c37adc894a478463376dd to your computer and use it in GitHub Desktop.
Delete zoom levels from an MBTiles file (set max zoom)
-- change 9 to whatever the max zoom level you want in your MBTiles
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