reVeal.overlay.calc_sum_attribute#

calc_sum_attribute(zones_df, dset_src, attribute, where=None, **kwargs)[source]#

Calculate the sum of the specified attribute for all features intersecting each zone in input zones dataframe. If no features intersect a given zone, a value of zero will be returned for that zone.

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 vector dataset with attribute to be summed. Must be in the same CRS as the zones_df.

  • attribute (str) – Name of attribute in dset_src to sum.

  • where (str, optional) – Optional query string to apply to the input dset_src to subset the features included in the results. Should follow the format expr defined in pandas.DataFrame.query.

  • **kwargs – Arbitrary keyword arguments. Note that none of these are used, but this allows passing an arbitrary dictionary that includes both used and unused parameters as input to the function.

Returns:

pandas.DataFrame – Returns a pandas DataFrame with a “value” column, representing the sum of the attribute of features in each zone. The index from the input zones_df is also included.