5
GeoPandas:查找其他数据框中的最近点
我有2个地理数据框: import geopandas as gpd from shapely.geometry import Point gpd1 = gpd.GeoDataFrame([['John',1,Point(1,1)],['Smith',1,Point(2,2)],['Soap',1,Point(0,2)]],columns=['Name','ID','geometry']) gpd2 = gpd.GeoDataFrame([['Work',Point(0,1.1)],['Shops',Point(2.5,2)],['Home',Point(1,1.1)]],columns=['Place','geometry']) 我想为gpd1中的每一行找到gpd2中最近点的名称: desired_output = Name ID geometry Nearest 0 John 1 POINT (1 1) Home 1 Smith 1 POINT (2 2) Shops 2 Soap 1 POINT (0 2) Work 我一直在尝试使用lambda函数使其工作: gpd1['Nearest'] = gpd1.apply(lambda row: min_dist(row.geometry,gpd2)['Place'] , …