GlacioHack / geoutils

Analysis of georeferenced rasters and vectors
https://geoutils.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
83 stars 19 forks source link

Add subsetting directly in `Vector.create_mask` #237

Open rhugonnet opened 3 years ago

rhugonnet commented 3 years ago

It seems we are using this kind of code quite often when we want to select one or several geometries (e.g., https://github.com/GlacioHack/xdem/blob/main/tests/test_volume.py#L22):

outlines = orig_outlines.copy()
outlines.ds = outlines.ds.loc[outlines.ds["NAME"] == "Scott Turnerbreen"]
mask_turnerbreen = outlines.create_mask(dem_2009)

I feel maybe it would make sense to have a wrapped functionality such as:

mask_turnerbreen = outlines.create_mask(dem_2009, feature_id={"NAME":"Scott Turnerbreen"}

For this, we wouldn't need to copy the entire Vector object. Selecting features in vector data is generally optimized at lower levels (I know OGR was quite efficient through SQL requests, but don't know too much about geopandas, I couldn't find any detail on rasterize in their documentation: https://geopandas.org/search.html?q=rasterize).

adehecq commented 3 years ago

Great idea !