reVeal.overlay.zonal_statistic#

zonal_statistic(zones_df, dset_src, stat, weights_dset_src=None, parallel=False, max_workers=None)[source]#

Calculate zonal statistic for the specified statistic. Convenience function that wraps zonal_statistic_serial() and zonal_statistic_parallel() functions,

Parameters:
  • zones_df (geopandas.GeoDataFrame) – Input zones dataframe, to which results will be aggregated. This function assumes that the index of zones_df is unique for each feature. If this is not the case, unexpected results may occur.

  • dset_src (str) – Path to input raster dataset to be summarized.

  • stat (str) – Zonal statistic to calculate. For valid options and compatability with use of weights, see: https://isciences.github.io/exactextract/operations.html#built-in-operations.

  • weights_dset_src (str, optional) – Optional path to datset to use for weights. Note that only some options for stat support use of weights. See stat for more information.

  • parallel (bool, optional) – If True, run the zonal statistic operation with parallel processing. If False (default), run with serial processing.

  • max_workers (int, optional) – If specified, sets the maximum number of workers used in parallel processing. By default, None, which will use all available workers.

Returns:

pandas.DataFrame – Returns a pandas DataFrame with a “value” column, representing the aggregate statistic of raster values within each zone. The index from the input zones_df is also included.