Skip to content

Instantly share code, notes, and snippets.

@AlanPew
Forked from rosskarchner/export.py
Created October 22, 2021 00:11
Show Gist options
  • Save AlanPew/d3a780e231f19067a4748de3bf48927b to your computer and use it in GitHub Desktop.
Save AlanPew/d3a780e231f19067a4748de3bf48927b to your computer and use it in GitHub Desktop.
extract tiles from an mbtiles file
import sqlite3, os
conn = sqlite3.connect('Mills1860.mbtiles')
results=conn.execute('select * from tiles').fetchall()
for result in results:
zoom, column, row, png= result
try:
os.makedirs('%s/%s/' % (zoom, row))
except:
pass
tile_out=open('%s/%s/%s.png' % (zoom, row, column), 'wb')
tile_out.write(png)
tile_out.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment