pyiem.grid.zs module#
Utility class to help with fast zonal_stats work
- pyiem.grid.zs.GRIDINFO#
alias of
GridInfo
- class pyiem.grid.zs.CachingZonalStats(affine)[source]#
Bases:
objectImplements a cache to speed up zonal_stats computation
Figure out how these geometries map to our grid
- Parameters:
grid (numpy.ndarray) – the array to sample values for
geometries (geopandas.GeoSeries) – geometries to compute over, this should not change over the lifetime of this object
- gen_stats(grid, geometries=None, stat=<numpy.ma.core._frommethod object>)[source]#
Compute the zonal_stats for the provided geometries and grid
Note: the passed grid should have (0,0) in upper-left, np.flipud()
- Parameters:
grid (numpy.ndarray) – the array to sample values for
geometries (geopandas.GeoSeries) – geometries to compute over, this should not change over the lifetime of this object
stat (function) – the function to compute over the masked grid
- Returns:
the ordered results of our work
- Return type: