def nearest(geom, gdf):
    """Find the element of a GeoDataFrame nearest a shapely geometry"""
    matches_idx = gdf.sindex.nearest(geom.bounds)
    nearest_geom = min(
        [gdf.iloc[match_idx] for match_idx in matches_idx],
        key=lambda match: geom.distance(match.geometry),
    )
    return nearest_geom