imod.prepare.zonal_aggregate_polygons#

imod.prepare.zonal_aggregate_polygons(path_a: Union[Path, str], path_b: Union[Path, str], column_a: str, column_b: str, like: DataArray, resolution: float, method: Union[str, Callable], chunksize: int = 10000.0) DataFrame[source]#

Compute a zonal aggregate of polygon data for (other) polygon geometries, e.g. a mean, mode, or percentile.

Parameters:
  • path_a (str or pathlib.Path) – path to OGR supported vector file (e.g. a shapefile)

  • path_b (str or pathlib.Path) – path to OGR supported vector file (e.g. a shapefile)

  • column_a (str) – column name of path_a. Defines zones of aggregation.

  • column_b (str) – column name of path_b. Data to aggregate.

  • resolution (float) – cellsize at which the rasterization, sampling, and area measurement occur.

  • method (Union[str, Callable]) – Aggregation method. Anything that is acceptable by a pandas groupby aggregate: https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.aggregate.html

  • like (xarray.DataArray with dims ("y", "x")) – Example DataArray of where the cells will be located. Used only for its x and y coordinates.

  • chunksize (int, optional) – The size of the chunksize. Used for both x and y dimension.

Returns:

zonal_aggregates

Return type:

pandas.DataFrame