我遵循这个教程最近的邻居分析:https://automating-gis-processes.github.io/2017/lessons/L3/nearest-neighbour.html
我知道这个错误:
('id', 'occurred at index 0')在我做完这个之后:
def nearest (row, geom_union, df1, df2, geom1_col='geometry', geom2_col='geometry', src_column=None):
# Find the nearest point and return the corresponding value from specified column.
# Find the geometry that is closest
nearest= df2[geom2_col] == nearest_points(row[geom1_col], geom_union)[1]
#Get the corresponding value from df2 (matching is based on the geometry)
value = df2[nearest][src_column].get_values()[0]
return value
df1['nearest_id'] = df1.apply(nearest, geom_union=unary_union, df1=df1, df2=df2, geom1_col='centroid', src_column='id', axis=1)我用我自己的数据来做这件事。它类似于给出的例子。但是我有一个shp文件的地址,几何学,纬度和经度。所以我不使用.kml文件。我找不出这个错误。
发布于 2019-11-19 21:26:38
你真的遵守了密码吗,
src_column='id',
1‘最近的_id’=df1.应用( geom_union=unary_union、df1=df1、df2=df2、GORG-1_col=‘质心’、df2=df2 axis=1)
然后问题很可能是src_column --函数返回列src_column参数的值,该参数由示例代码给出值id。如果列id出现问题,则很可能没有这样名称的列,应该在数据集中提供现有列的名称。
https://stackoverflow.com/questions/58938702
复制相似问题