python-rasterstats icon indicating copy to clipboard operation
python-rasterstats copied to clipboard

Multigeometries

Open yyu1 opened this issue 3 years ago • 1 comments

Here is the code to enable the "split_multi_geom" option for zonal_stats as we discussed. It reads individual polygons in a multipolygon type of geometry to save memory usage.

I only did a bare minimum of testing against the slope.tif and multipolygon.shp inside the test directory. I don't really have the data and time to do more extensive testing. So perhaps some of the users asking for this feature can do some tests.

yyu1 avatar Feb 10 '22 09:02 yyu1

In case it is useful for future users looking to address memory issues, I submitted a PR a while back that takes this concept one step further and can split polygons into smaller polygons to reduce memory usage (then aggregates stats back at the end to original polygons).

https://github.com/perrygeo/python-rasterstats/pull/154

My fork with this feature is a bit outdated and includes some other features required for my application, but if needed it is available here: https://github.com/aiddata/python-rasterstats

sgoodm avatar Feb 10 '22 13:02 sgoodm