-
Notifications
You must be signed in to change notification settings - Fork 0
Mapbox
Claus Höfele edited this page Sep 13, 2015
·
10 revisions
Mapbox Studio allows to export vector data sources in the MBTiles format:
- Open or create new source project (note: don't use a style project)
- Save project
- Go to Settings and click Export to MBTiles
- Download and save the exported data
The resulting file is an SQLite database that includes the vector data.
MBTiles files can be read with the sqlite3 tool (preinstalled on Mac OS X).
$ sqlite3 test.mbtiles
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> .tables
geocoder_data grid_key grids keymap metadata
grid_data grid_utfgrid images map tiles
The MBTiles database contains vector data if the format specifier returns pbf (i.e. Protocol Buffers):
sqlite> select value from metadata where name = "format";
pbf
Use the following steps to export vector data:
-
.dump images, then choose a tile ID to export (e.g.f93dd1408623fbc191025a00e057a338) - Use this tile ID to extract the zipped PBF data into a file (e.g. named
tile_data.zip)
sqlite3 de.mbtiles "select quote(images.tile_data) from images where images.tile_id = 'f93dd1408623fbc191025a00e057a338';" | cut -d "'" -f2 | xxd -r -p > tile_data.zip
- Unzip the resulting file by double-clicking on it (results in a file called
tile_data) - Install the
protobuffertool if necessary viabrew install protobuf - Download the latest PBF schema file for Mapbox's vector tiles
- Use the schema file to look at the contents of the data:
$ protoc --decode=vector_tile.Tile vector_tile.proto < tile_data
layers {
name: "de"
features {
id: 1
tags: 0
tags: 0
type: POLYGON
geometry: 9
geometry: 8448
geometry: 255
geometry: 34
geometry: 0
geometry: 8704
geometry: 8703
geometry: 0
geometry: 0
geometry: 8703
geometry: 8704
geometry: 0
geometry: 15
}
keys: "name"
values {
string_value: "Germany"
}
extent: 4096
version: 1
}