How do I find what data is in a .mbtiles file that I've created?

(a related previous question is this one from 2011)

Using Tilemaker**, I’ve created a .mbtiles file. Using a sample map I can see that the data that I’d expect to be in there is. However, can I analyse the .mbtiles file directly to see what is in it, how much space the data at each zoom level takes, what data is present at each zoom level etc.?

It’s a sqlite database, so I can dump the contents out easily enough:

sqlite3 blah.mbtiles
SQLite version 3.37.2 2022-01-06 13:25:41
Enter ".help" for usage hints.
sqlite> .output blah.txt
sqlite> .dump
sqlite> .exit

I get something like this:

PRAGMA foreign_keys=OFF;
CREATE TABLE metadata (name text, value text, UNIQUE (name));
INSERT INTO metadata VALUES('name','SVE01');
INSERT INTO metadata VALUES('type','baselayer');
INSERT INTO metadata VALUES('version','0.1');
INSERT INTO metadata VALUES('description','SVE01 - based on Tilemaker example');
INSERT INTO metadata VALUES('format','pbf');
INSERT INTO metadata VALUES('minzoom','0');
INSERT INTO metadata VALUES('maxzoom','14');
INSERT INTO metadata VALUES('bounds','-2.567177,53.619990,-0.040615,54.702224');
INSERT INTO metadata VALUES('center','-1.303896,54.161107,7');
INSERT INTO metadata VALUES('json','{"vector_layers":[{"id":"transportation","description":"transportation",    "fields":{"class":"String","edge":"String"}},{"id":"waterway","description":"waterway","fields":{"class":"St    ring"}},{"id":"building","description":"building","fields":{}}]}');
CREATE TABLE tiles (zoom_level integer, tile_column integer, tile_row integer, tile_data blob, UNIQUE (zoom_    level, tile_column, tile_row));
INSERT INTO tiles VALUES(4,7,10,X'1f8b080000000000000303000000000000000000');
INSERT INTO tiles VALUES(3,3,5,X'1f8b080000000000000303000000000000000000');
INSERT INTO tiles VALUES(8,126,174,X'1f8b080000000000000 ... snip ... ff3fce55244eef6c0600');
INSERT INTO tiles VALUES(0,0,0,X'1f8b080000000000000303000000000000000000');
CREATE UNIQUE INDEX tile_index on tiles (zoom_level, tile_column, tile_row);

Obviously the actual data in some of the database “fields” needs further decoding - is there anything that already exists that can report on this?

** Obviously plenty of other tools are available and my question isn’t specific just to Tilemaker.

4 posts - 4 participants

Read full topic

Ce sujet de discussion accompagne la publication sur