我有2个数据帧。 1)数据-长点和纬度点2)边界=城市的shapefile
我需要检查shapefile中的哪些点并保存。这是我的代码:
city = pd.read_csv("D:...path.../data.csv")
crs = {'init':'epsg:4326'}
geometry = [Point(xy) for xy in zip(city.longitude,city.latitude)]
city_point = gpd.GeoDataFrame(city,crs=crs,geometry=geometry)
border = gpd.read_file("C:...path.../border.shp")
border_gdf = gpd.GeoDataFrame(border, geometry='geometry')
city_point['inside'] = city_point['geometry'].apply(border_gdf.contains)
city_point = city_point[city_point.inside != True]
import numpy as np
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point, Polygon
答案 0 :(得分:0)
city_point[city_point.geometry.within(border_gdf.iloc[0].geometry)]