I have a set of coordinates in Egypt and some of these coordinates appear in the Mediterranean Sea when plotted in a map. There are many coordinates like this and I would have a difficult time removing them manually. So is there any way to do this by code either in SQL or by using Python.
Asked
Active
Viewed 31 times
1 Answers
0
You can use geopandas for that, but you need the geometry for the mediterranean sea.
import geopandas as gpd
# Load location data into a GeoDataFrame
locations = gpd.read_file('location_data.shp')
# Load data for the Mediterranean Sea region into a GeoDataFrame
mediterranean_sea = gpd.read_file('mediterranean_sea_data.shp')
# Exclude all locations within the Mediterranean Sea region
locations_outside = locations[~locations.within(mediterranean_sea.geometry)]
# Save the resulting GeoDataFrame to a shapefile
locations_outside.to_file('locations_outside_mediterranean_sea.shp')

Alejo Cuartas
- 26
- 4