Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tile_data column doesn't seem to be an image #13

Closed
AndreMiras opened this issue Aug 1, 2015 · 2 comments
Closed

tile_data column doesn't seem to be an image #13

AndreMiras opened this issue Aug 1, 2015 · 2 comments

Comments

@AndreMiras
Copy link
Contributor

Isn't "tile_data" supposed to be jpg or png image?
Because when I dump it to a file it's not recognised as an image, but just "data".

This is the script I used for dumping:

#!/usr/bin/env python2
import sys
import sqlite3
import tempfile

database = sys.argv[1]
conn = sqlite3.connect(database)
c = conn.cursor()
c.execute("SELECT zoom_level, tile_column, tile_row, tile_data FROM tiles")
row = c.fetchone()
(zoom_level, tile_column, tile_row, tile_data) = row
# we're only interested in non-empty data
while len(tile_data) == 0:
    row = c.fetchone() # fetch next one
    (zoom_level, tile_column, tile_row, tile_data) = row
    # print "row(zoom_level, tile_column, tile_row, tile_data):", row
conn.close()
f = tempfile.NamedTemporaryFile(delete=False, suffix=".data")
f.write(tile_data)
f.close()
print "tile_data dumped to:", f.nam

Running the script:

$ ./dump_tile_data.py languedoc-rousillon.mbtiles 
tile_data dumped to: /tmp/tmpwJ1G_H.data
$ file /tmp/tmpwJ1G_H.data
/tmp/tmpwJ1G_H.data: data

However, when I try with another mbtiles which is not made from Tilemaker, the dumped data is actually a png:

$ ./dump_tile_data.py montpellier.mbtiles 
tile_data dumped to: /tmp/tmpyMet0n.data
$ file /tmp/tmpyMet0n.data
/tmp/tmpyMet0n.data: PNG image data, 256 x 256, 8-bit colormap, non-interlaced

Additional information:

  • languedoc-rousillon.mbtiles was generated with Tilemaker (master branch 6a994ee) and "compress": false, the pbf was downloaded from Geofabrik
  • montpellier.mbtiles was generated with makinacorpus/landez
@systemed
Copy link
Owner

systemed commented Aug 1, 2015

It's meant to be a .pbf vector tile. Tilemaker makes vector tiles which you can use with an in-browser renderer, such as Mapbox GL, Tangram, or Leaflet.MapboxVectorTile; or you can use them as the foundation of a Mapnik-based rendering stack. It doesn't itself produce raster images like jpeg or png; if that's your aim you still need Mapnik or similar.

@systemed systemed closed this as completed Aug 1, 2015
@AndreMiras
Copy link
Contributor Author

Great, thank you for the hint!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants