Geopandas统计同覆盖小区
Geopandas统计同覆盖小区defsamefugei_updata(distm,agleabs):#distm:同覆盖距离单位米agleabs:同覆盖小区经纬度差dis_buffer distmagle_abs agleabsfile_yuan ./原始数据\\工参表.xlsxdirout ./输出结果\\p_yuan pd.read_excel(file_yuan,sheet_name主小区)p_mubiao pd.read_excel(file_yuan,sheet_name目标小区)point gpd.GeoDataFrame(p_yuan,geometrygpd.points_from_xy(p_yuan.经度, p_yuan.纬度),crsEPSG:4326)point point.to_crs(EPSG:2381)#计算距离到米point_mubiao gpd.GeoDataFrame(p_mubiao,geometrygpd.points_from_xy(p_mubiao[经度-目标小区], p_mubiao[纬度-目标小区]),crsEPSG:4326)point_mubiao point_mubiao.to_crs(EPSG:2381)point_mubiao[point_2]point_mubiao[geometry]point_mubiao point_mubiao.set_geometry(point_2)point_buffer point.buffer(dis_buffer)plogy_1point.copy()plogy_1[point_buffer] point_bufferplogy_1[point] plogy_1[geometry]plogy_1 plogy_1.set_geometry(point_buffer)gp_ponitboder gpd.sjoin(point_mubiao, plogy_1)print(gp_ponitboder.dtypes)gp_ponitboder[diatac(米)]gp_ponitboder[point_2].distance(gp_ponitboder[point],alignFalse)p_df pd.DataFrame()p_df pd.concat([p_df, gp_ponitboder])p_df[方位角差_abs] np.abs(p_df[方位角] - p_df[方位角-目标小区])p_df[同覆盖] np.where(p_df[方位角差_abs] agle_abs,同覆盖,不同覆盖)p_df[同小区]np.where(p_df[eci] p_df[eci-目标小区],同小区,不同小区)p_df p_df[(p_df[同覆盖] 同覆盖)(p_df[同小区]不同小区)]order [地市,小区名称,enodbid,cellid,经度,纬度,eci,方位角,小区名称--目标小区,enodbid-目标小区,cellid-目标小区,经度-目标小区,纬度-目标小区,eci-目标小区,方位角-目标小区,方位角差_abs,同覆盖,diatac(米)]p_df p_df[order]fileout dirout 同覆盖小区明细.csvp_df.to_csv(fileout,encodingANSI,indexFalse)