def _area_tables_binning(source_df, target_df, spatial_index):
    'Construct area allocation and source-target correspondence tables using a spatial indexing approach\n    ...\n\n    NOTE: this currently relies on Geopandas\' spatial index machinery\n\n    Parameters\n    ----------\n    source_df : geopandas.GeoDataFrame\n        GeoDataFrame containing input data and polygons\n    target_df : geopandas.GeoDataFramee\n        GeoDataFrame defining the output geometries\n    spatial_index : str\n        Spatial index to use to build the allocation of area from source to\n        target tables. It currently support the following values:\n            - "source": build the spatial index on `source_df`\n            - "target": build the spatial index on `target_df`\n            - "auto": attempts to guess the most efficient alternative.\n              Currently, this option uses the largest table to build the\n              index, and performs a `bulk_query` on the shorter table.\n\n    Returns\n    -------\n    tables : scipy.sparse.dok_matrix\n\n    '
    if _check_crs(source_df, target_df):
        pass
    else:
        return None
    df1 = source_df.copy()
    df2 = target_df.copy()
    if (spatial_index == 'auto'):
        if (df1.shape[0] > df2.shape[0]):
            spatial_index = 'source'
        else:
            spatial_index = 'target'
    if (spatial_index == 'source'):
        (ids_tgt, ids_src) = df1.sindex.query_bulk(df2.geometry, predicate='intersects')
    elif (spatial_index == 'target'):
        (ids_src, ids_tgt) = df2.sindex.query_bulk(df1.geometry, predicate='intersects')
    else:
        raise ValueError(f"'{spatial_index}' is not a valid option. Use 'auto', 'source' or 'target'.")
    areas = df1.geometry.values[ids_src].intersection(df2.geometry.values[ids_tgt]).area
    table = coo_matrix((areas, (ids_src, ids_tgt)), shape=(df1.shape[0], df2.shape[0]), dtype=np.float32)
    table = table.todok()
    return table
Construct area allocation and source-target correspondence tables using a spatial indexing approach
...

NOTE: this currently relies on Geopandas' spatial index machinery

Parameters
----------
source_df : geopandas.GeoDataFrame
    GeoDataFrame containing input data and polygons
target_df : geopandas.GeoDataFramee
    GeoDataFrame defining the output geometries
spatial_index : str
    Spatial index to use to build the allocation of area from source to
    target tables. It currently support the following values:
        - "source": build the spatial index on `source_df`
        - "target": build the spatial index on `target_df`
        - "auto": attempts to guess the most efficient alternative.
          Currently, this option uses the largest table to build the
          index, and performs a `bulk_query` on the shorter table.

Returns
-------
tables : scipy.sparse.dok_matrix
def _area_tables_binning(source_df, target_df, spatial_index):
    'Construct area allocation and source-target correspondence tables using a spatial indexing approach\n    ...\n\n    NOTE: this currently relies on Geopandas\' spatial index machinery\n\n    Parameters\n    ----------\n    source_df : geopandas.GeoDataFrame\n        GeoDataFrame containing input data and polygons\n    target_df : geopandas.GeoDataFramee\n        GeoDataFrame defining the output geometries\n    spatial_index : str\n        Spatial index to use to build the allocation of area from source to\n        target tables. It currently support the following values:\n            - "source": build the spatial index on `source_df`\n            - "target": build the spatial index on `target_df`\n            - "auto": attempts to guess the most efficient alternative.\n              Currently, this option uses the largest table to build the\n              index, and performs a `bulk_query` on the shorter table.\n\n    Returns\n    -------\n    tables : scipy.sparse.dok_matrix\n\n    '
    if _check_crs(source_df, target_df):
        pass
    else:
        return None
    df1 = source_df.copy()
    df2 = target_df.copy()
    if (spatial_index == 'auto'):
        if (df1.shape[0] > df2.shape[0]):
            spatial_index = 'source'
        else:
            spatial_index = 'target'
    if (spatial_index == 'source'):
        (ids_tgt, ids_src) = df1.sindex.query_bulk(df2.geometry, predicate='intersects')
    elif (spatial_index == 'target'):
        (ids_src, ids_tgt) = df2.sindex.query_bulk(df1.geometry, predicate='intersects')
    else:
        raise ValueError(f"'{spatial_index}' is not a valid option. Use 'auto', 'source' or 'target'.")
    areas = df1.geometry.values[ids_src].intersection(df2.geometry.values[ids_tgt]).area
    table = coo_matrix((areas, (ids_src, ids_tgt)), shape=(df1.shape[0], df2.shape[0]), dtype=np.float32)
    table = table.todok()
    return table