geomesher.area_weighted#
Area Weighted Interpolation based on tobler.
Module Contents#
- geomesher.area_weighted.area_interpolate(source_df, target_df, extensive_variables=None, intensive_variables=None, categorical_variables=None, table=None, allocate_total=True, spatial_index='auto')[source]#
Area interpolation for extensive, intensive and categorical variables.
- Parameters:
source_df (
geopandas.GeoDataFrame) – The source dataframe to get values from.target_df (
geopandas.GeoDataFrame) – The target dataframe to interpolate the values fromsource_df.extensive_variables (
list, optional) – Columns in dataframes for extensive variables, defaults toNone.intensive_variables (
list, optional) – Columns in dataframes for intensive variables, defaults toNone.categorical_variables (
list, optional) – Columns in dataframes for categorical variables, defaults toNone.table (
scipy.sparse.csr_matrix, optional) – Area allocation source-target correspondence table. If not provided, it will be built fromsource_dfandtarget_df.allocate_total (
boolean, optional) – True if total value of source area should be allocated. False if denominator is area of i. Note that the two cases would be identical when the area of the source polygon is exhausted by intersections. See Notes for more details. Defaults to True.spatial_index (
str, optional) – Spatial index to use to build the allocation of area from source to target tables, defaults toauto. It currently supports the following values:source: build the spatial index onsource_dftarget: build the spatial index ontarget_dfauto: attempts to guess the most efficient alternative.Currently, this option uses the largest table to build the index, and performs a
queryon the shorter table.
- Returns:
geopandas.GeoDataFrame– new geodaraframe with interpolated variables as columns andtarget_dfgeometry as output geometry- Return type:
Notes
The assumption is both dataframes have the same coordinate reference system. For an extensive variable, the estimate at target polygon \(j\) (default case) is:
\[ \begin{align}\begin{aligned}v_j = \sum_i v_i w_{i,j}\\w_{i,j} = \frac{a_{i,j}}{\sum_k a_{i,k}}\end{aligned}\end{align} \]If the area of the source polygon is not exhausted by intersections with target polygons and there is reason to not allocate the complete value of an extensive attribute, then setting
allocate_total=Falsewill use the following weights:\[ \begin{align}\begin{aligned}v_j = \sum_i v_i w_{i,j}\\w_{i,j} = \frac{a_{i,j}}{a_i}\end{aligned}\end{align} \]where \(a_i\) is the total area of source polygon \(i\). For an intensive variable, the estimate at target polygon \(j\) is:
\[ \begin{align}\begin{aligned}v_j = \sum_i v_i w_{i,j}\\w_{i,j} = \frac{a_{i,j}}{\sum_k a_{k,j}}\end{aligned}\end{align} \]For categorical variables, the estimate returns ratio of presence of each unique category.