Skip to content

Instantly share code, notes, and snippets.

@maning
Forked from rosskarchner/export.py
Created January 12, 2012 01:54
Show Gist options
  • Save maning/1598027 to your computer and use it in GitHub Desktop.
Save maning/1598027 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