def _get_potentially_intersecting_lines(traj, polygon):
    """
    Uses a spatial index to determine which parts of the trajectory may be intersecting with the polygon

    Returns
    -------
    possible_matches : GeoDataFrame
        GeoDataFrame of potentially intersecting lines
    """
    line_df = traj._to_line_df()
    spatial_index = line_df.sindex
    if spatial_index:
        possible_matches_index = list(spatial_index.intersection(polygon.bounds))
        possible_matches = line_df.iloc[possible_matches_index].sort_index()
    else:
        possible_matches = line_df
    return possible_matches