def _intersect_index_quadrats(
    geoms: gpd.GeoSeries,
    polygon: Polygon | MultiPolygon,
) -> set[Any]:
    """
    Identify geometries that intersect a (Multi)Polygon.

    Uses an r-tree spatial index and cuts polygon up into smaller sub-polygons
    for r-tree acceleration. Ensure that geometries and polygon are in the
    same coordinate reference system.

    Parameters
    ----------
    geoms
        The geometries to intersect with the polygon.
    polygon
        The polygon to intersect with the geometries.

    Returns
    -------
    geoms_in_poly
        The index labels of the geometries that intersected the polygon.
    """
    # create an r-tree spatial index for the geometries
    rtree = geoms.sindex
    msg = f"Built r-tree spatial index for {len(geoms):,} geometries"
    utils.log(msg, level=lg.INFO)

    # cut polygon into chunks for faster spatial index intersecting. specify a
    # sensible quadrat_width to balance performance (eg, 0.1 degrees is approx
    # 8 km at NYC's latitude) with either projected or unprojected coordinates
    quadrat_width = max(0.1, np.sqrt(polygon.area) / 10)
    multipoly = _quadrat_cut_geometry(polygon, quadrat_width)
    msg = f"Accelerating r-tree with {len(multipoly.geoms)} quadrats"
    utils.log(msg, level=lg.INFO)

    # loop through each chunk of the polygon to find intersecting geometries
    # first find approximate matches with spatial index, then precise matches
    # from those approximate ones
    geoms_in_poly = set()
    for poly in multipoly.geoms:
        poly_buff = poly.buffer(0)
        if poly_buff.is_valid and poly_buff.area > 0:
            possible_matches_iloc = rtree.intersection(poly_buff.bounds)
            possible_matches = geoms.iloc[list(possible_matches_iloc)]
            precise_matches = possible_matches[possible_matches.intersects(poly_buff)]
            geoms_in_poly.update(precise_matches.index)

    msg = f"Identified {len(geoms_in_poly):,} geometries inside polygon"
    utils.log(msg, level=lg.INFO)
    return geoms_in_poly

    Identify geometries that intersect a (Multi)Polygon.

    Uses an r-tree spatial index and cuts polygon up into smaller sub-polygons
    for r-tree acceleration. Ensure that geometries and polygon are in the
    same coordinate reference system.

    Parameters
    ----------
    geoms
        The geometries to intersect with the polygon.
    polygon
        The polygon to intersect with the geometries.

    Returns
    -------
    geoms_in_poly
        The index labels of the geometries that intersected the polygon.
    
osmnx/utils_geo.py