PYTHON根据楼宇或建筑面信息(buildings.shp)提取CSV里经纬度落在楼宇或建筑物的数据

import pandas as pd
import geopandas as gpd
from shapely.geometry import Point

读取.csv文件中的经纬度数据

#df = pd.read_csv(‘./4g_table.csv’,delimiter=‘|’)
df = pd.read_csv(‘./all.csv’)

创建楼宇面的GeoDataFrame

buildings = gpd.read_file(‘buildings.shp’)

判断每个经纬度点是否在楼宇面内,返回True或False

df[‘is_inside’] = [buildings.geometry.contains(Point(lon, lat))[0] for lon, lat in zip(df[‘flong_u’], df[‘flat_u’])]

输出结果

#print(df)
df=df[df[‘is_inside’]==True]

df.to_csv(‘./output_true.csv’,index=False)

你可能感兴趣的:(python)