Seemingly misleading tilestats when a source has more than 1 geometry type
zabop opened this issue · 0 comments
Recently I noticed that I find the tilestats section of the metadata.json slightly surprising.
Short summary: I created a GeoJSON file with 3 geometries: a point, a line, and a polygon. I processed it using tippecanoe (creating both an mbtiles file and a directory tree of pbf files). All 3 input geometries show up in QGIS when the mbtiles file is loaded. However, the tilestats section of metadata.json only mentions Point
as geometry.
Steps to reproduce the issue
Create example GeoJSON file:
#!/usr/bin/python3
import geopandas as gpd
import shapely.geometry
point = shapely.geometry.Point(12, 34)
linestring = shapely.geometry.LineString([[10,20],[-30,40]])
polygon = shapely.geometry.Polygon([[0,0],[0,10],[10,10],[0,0]])
gpd.GeoSeries([point,linestring,polygon]).set_crs(4326).to_file("example.geojson")
Tile data to an mbtiles file:
tippecanoe -Z2 -z10 -o out.mbtiles example.geojson
Tile data to a directory tree:
tippecanoe -Z2 -z10 -e out example.geojson
Open mbtiles file in QGIS:
![image](https://private-user-images.githubusercontent.com/20886570/312114184-6a678742-391c-4b4b-80ac-425ed9eaff80.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE4NjU0MzQsIm5iZiI6MTcyMTg2NTEzNCwicGF0aCI6Ii8yMDg4NjU3MC8zMTIxMTQxODQtNmE2Nzg3NDItMzkxYy00YjRiLTgwYWMtNDI1ZWQ5ZWFmZjgwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI0VDIzNTIxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU3ZThhNjQ2OGVhOTg0ODViOWJhNjQwNDZkN2VjNWE4YjYxNDk4NTc4Y2Y5MjgxMzc3ODY4NWE2NDY1MjQ4YTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.CrM5Ho5bwgFU07zcqrNV00P7GkDoxzPp4ZJ43o68cfk)
Features show up as expected. Inspect the tilestats section of metadata.json
:
cat out/metadata.json | jq '.json' | jq -c '. | fromjson' | jq '.tilestats'
Get:
{
"layerCount": 1,
"layers": [
{
"layer": "example",
"count": 3,
"geometry": "Point",
"attributeCount": 0,
"attributes": []
}
]
}
It's nice that we have "count": 3
(we started with 3 features). However, why do we have "geometry": "Point"
?
I think it would be nice to have ["Point","LineString","Polygon"]
instead, for example. Or some other value which enables users to know that not only Point geometries where used to create the tiles. Alternatively, I think an option forcing tippecanoe to fail if tilestats
doesn't accurately represent input geometries (perhaps --be-strict-with-tilestats
?) would be very useful.
Thanks for sharing some insights on the matter :) Tippecanoe is awesome, thanks a lot for developing it.