-
Notifications
You must be signed in to change notification settings - Fork 9
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
Proposal: options for zonal_statistics
rasterization algorithm
#312
Comments
James shared a link for the gdal rasterization source: https://github.com/OSGeo/gdal/blob/89e3fc244652771ca4f8abc0a6fe5794e2201b26/alg/gdalrasterize.cpp#L759 |
Dave shared some background from what QGIS is doing: |
We determined that this needs some more information to make a decision -
|
Here's another zonal stats library to keep an eye on. I think python bindings are in the works. https://github.com/isciences/exactextract Their readme also includes a comparison of other implementations. |
Here's the interesting bit of how QGIS handles very small polygons relative to the grid size:
|
In our discussion today I think the general take aways were:
|
|
how it works now
zonal_statistics
rasterizes aggregate polygons. GDAL provides two options:ALL_TOUCHED=False
(default): pixels are "burned in" to the raster if their centerpoint falls within the aggregate polygonALL_TOUCHED=True
: pixels are "burned in" to the raster if they touch the aggregate polygon at allzonal_statistics
usesALL_TOUCHED=False
. Some aggregate polygons can end up with no pixels at all (if they don't happen to overlap any pixels' centerpoint).zonal_statistics
handles this case like so:proposed changes
Add a kwarg
all_touched=False
tozonal_statistics
. Pass this value togdal.RasterizeLayer
. Remove the special handling of unset polygons.all_touched=False
, the results will generally be more similar to the current version, but it's possible that some polygons will have no stats calculated (if they don't overlap any pixel centerpoint).all_touched=True
, it's guaranteed that all polygons within the defined area of the raster will have stats calculated.benefits
examples
The text was updated successfully, but these errors were encountered: