reVeal.overlay.calc_sum#

calc_sum(zones_df, dset_src, weights_dset_src, parallel=False, max_workers=None, **kwargs)[source]#

Calculate zonal sum or weighted sum of raster values over the input zones.

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.

  • weights_dset_src (str, optional) – Optional path to datset to use for weights. If specified, the sum for each zone will be weighted based on the values in this dataset.

  • 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 sum or weighted sum of raster values within each zone. The index from the input zones_df is also included.