I am visualizing data points from an Uber drives in New South Wales of Australia dataset on a Folium map, but some of the data points were inside the sea instead of being on the mainland, I tried using a polygon data set of the New South Wales of Australia so that I can use GeoDataFrame.sjoin
on both data sets with the "contains" predicate, however, some of the points are still outside, how can I solve this?
This is my code
geo_df = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df.pick_up_lon, df.pick_up_lat), crs="EPSG:4326")
poly_df = gpd.read_file("state.geojson")
join_df = gpd.sjoin(poly_df, geo_df, predicate="contains")
[before applying the polygon] [1]: https://i.stack.imgur.com/9yF82.jpg
[after applying the polygon and the sjoin, you can still see points outside the polygon in the sea] [2]: https://i.stack.imgur.com/f6FgR.jpg