Zonal Statistics¶
This module supports you in computing statistics over spatial zones. A typical application would be to compute mean areal precipitation for a catchment by using precipitation estimates from a radar grid in polar coordinates or from precipitation estimates in a Cartesian grid.
The general usage is similar to the wradlib.ipol
and
wradlib.adjust
:
You have to create an instance of a class (derived from
ZonalDataBase
) by using
the spatial information of your source and target objects (e.g. radar bins and
catchment polygons). The Zonal Data within this object can be saved eg. as an
ESRI Shapefile.
This object is then called with another class to compute zonal statistics for your target objects by calling the class instance with an array of values (one for each source object).
Typically, creating the instance of the ZonalData class will be computationally expensive, but only has to be done once (as long as the geometries do not change).
Calling the objects with actual data, however, will be very fast.
Note
Right now we only support a limited set of 2-dimensional zonal statistics. In the future, we plan to extend this to three dimensions.
DataSource |
DataSource class for handling ogr/gdal vector data |
ZonalDataBase |
Base class for managing 2-dimensional zonal data. |
ZonalDataPoint |
ZonalData object for source points |
ZonalDataPoly |
ZonalData object for source polygons |
ZonalStatsBase |
Base class for all 2-dimensional zonal statistics. |
ZonalStatsPoly |
Compute weighted average for target polygons based on areal weights. |
ZonalStatsPoint |
Compute zonal average from all points in or close to the target polygon. |
mask_from_bbox |
Return 2-d index array based on spatial selection from a bounding box. |
get_bbox |
Return bbox dictionary that represents the extent of the points. |
grid_centers_to_vertices |
Produces array of vertices from grid’s center point coordinates. |
get_clip_mask |
Returns boolean mask of points coords inside polygon clippoly |