Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions README

This file was deleted.

21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# MBTiles Extractor

### Usage

1) Save convert.py into the same folder as your .mbtiles file
2) Make sure python is installed
3) In terminal, cd into that folder
4) Run this:

```python
python convert.py filename.mbtiles
```

5) If you prefer XYZ schema instead of TMS run this:

```python
python convert.py filename.mbtiles XYZ
```

That's it! It should generate a folder called filename filled with PNGs that contain the data in the mbtiles archive.
15 changes: 11 additions & 4 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ def setDir(d):
######################################
# Let's do shit

if not len(sys.argv) == 2:
print 'Please provide exactly 1 parameter - the mbtiles input filename'
if not len(sys.argv) >= 2:
print 'Please provide at least 1 parameter - the mbtiles input filename'
exit()

if len(sys.argv) == 3:
output_schema = sys.argv[2]
else:
output_schema = 'TMS'
# Process input
input_filename = sys.argv[1]
dirname = input_filename[0:input_filename.index('.')]
Expand Down Expand Up @@ -53,10 +57,13 @@ def setDir(d):
for row in cursor:
setDir(str(row[0]))
setDir(str(row[1]))
output_file = open(str(row[2]) + out_format, 'wb')
if output_schema == 'XYZ':
output_file = open(str(((2**row[0]) - row[2] - 1)) + out_format, 'wb')
else:
output_file = open(str(row[2]) + out_format, 'wb')
output_file.write(row[3])
output_file.close()
os.chdir('..')
os.chdir('..')

print 'Done!'
print 'Done!'