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

support for featurerank in PMTiles creation #9829

Open
cboettig opened this issue May 1, 2024 · 5 comments
Open

support for featurerank in PMTiles creation #9829

cboettig opened this issue May 1, 2024 · 5 comments

Comments

@cboettig
Copy link

cboettig commented May 1, 2024

Feature description

Thanks for the amazing support for PMTiles in GDAL. This works incredibly well and has been a great pleasure to teach to students!

tippecanoe creation of pmtiles supports an notion of filter by scalerank. This can be useful in controlling which features appear at which zoom levels -- e.g. if we are mapping roads or rivers and want only main arteries to visible at low zooms and see the tiny branches only at high zooms. Would it be possible add such an ability to the layer creation options of pmtiles in gdal?

Additional context

No response

@rouault
Copy link
Member

rouault commented May 1, 2024

supports an notion of filter by scalerank.

not sure what "scalerank" mean: is that just a particular attribute of the NaturalEarth input layer ?
You could possibly apply standard OGR filters to create input layers for each zoom level with ogr2ogr and they use a layer configuration to map them to PMTiles zoom level: https://gdal.org/drivers/vector/pmtiles.html#layer-configuration

More generally, OGR remains a generic purpose tool and doesn't intend to compete tippecanoe in the special job of creating vector tiled datasets.

@rouault
Copy link
Member

rouault commented May 1, 2024

not sure what "scalerank" mean: is that just a particular attribute of the NaturalEarth input layer ?

ok, so checking with a NaturalEarth dataset, "scalerank" is just a regular attribute of that dataset.

So for a simple use case where you don't need to have different filter on scalerank by zoom level, the following would do:
ogr2ogr out.pmtiles in.shp -where "scalerank < 3"

@cboettig
Copy link
Author

cboettig commented May 1, 2024

ah right, yeah, sorry for the confusion, right any regular attribute of the vector. Thanks, I didn't know about where, though I know I can filter out features entirely using sf or geopandas. Would be really key though if the filtering was a function of zoom level. I think ideally this would take the form of some kind of map (maybe similar to how gdal handles a colormap), where at each zoom level we can indicate not to include features with a value that meets a certain criteria?

@rouault
Copy link
Member

rouault commented May 1, 2024

Would be really key though if the filtering was a function of zoom level. I think ideally this would take the form of some kind of map (maybe similar to how gdal handles a colormap), where at each zoom level we can indicate not to include features with a value that meets a certain criteria?

yes, all of that is of course the natural way of to do it, but that doesn't fit very well in the way the generic purpose ogr2ogr tool operates.
Hence what I sketched very roughly above.
More detailed example would be (I may have inverted the where conditions, but you get it):

ogr2ogr temp.gpkg in.shp -where "scalerank < 3" -nln "zoom_level_0"
ogr2ogr -update temp.gpkg in.shp -where "scalerank >= 3" -nln "zoom_level_1"
ogr2ogr out.pmtiles temp.gpkg -dsco CONF='{ "zoom_level_0": { "target_name": "my_layer", "minzoom": 0, "maxzoom": 0 },  "zoom_level_1": { "target_name": "my_layer", "minzoom": 1, "maxzoom": 1 } }'

@cboettig
Copy link
Author

cboettig commented May 1, 2024

ah ok, maybe this is out of scope for ogr2ogr, that's obviously your call to make! ogr2ogr an gdal_translate support so many impressive abilities already it's hard for me to sense what is and isn't out of scope, so feel free to close this if so. Thanks for the example above, that's quite a clever approach that hadn't occurred to me!

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

No branches or pull requests

2 participants