reVeal.overlay.calc_area#
- calc_area(zones_df, dset_src, weights_dset_src, parallel=False, max_workers=None, **kwargs)[source]#
Calculate the area of a raster within each zone. This function works by summing the raster values in each zone and then multiplying by the pixel size. See assumptions under dset_src.
- 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. This function assumes that the values in this dataset range from 0 to 1, indicating the fraction of the pixel to count when summing the total area in the zone. If the input raster’s values do no range from 0 (no inclusion) to 1 (full inclusion), the output results may be nonsensical.
weights_dset_src (str, optional) – Optional path to datset to use for weights. If specified, the area 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 total area (or weighted area) of the raster within each zone. The index from the input zones_df is also included.