在同一GeodataFrame中的每个点的半径中查找点
我有GeodataFrame:
df = gpd.GeoDataFrame([[0, 'A', Point(10,12)],
[1, 'B', Point(14,8)],
[2, 'C', Point(100,2)],
[3, 'D' ,Point(20,10)]],
columns=['ID','Value','geometry'])
是否有可能在每个点的半径范围内找到点,并将其“值”和“几何”和“几何”添加到GeoDataFrame
['ID','Value','geometry','value_of_point_in_range_1','geometry_of_point_in_range_1','value_of_point_in_range_2','geometry_of_point_in_range_2' etc.]
中正在检查是否在范围内,但我必须在半径中找到所有要点,并且不知道我应该使用什么工具。
I have geoDataFrame:
df = gpd.GeoDataFrame([[0, 'A', Point(10,12)],
[1, 'B', Point(14,8)],
[2, 'C', Point(100,2)],
[3, 'D' ,Point(20,10)]],
columns=['ID','Value','geometry'])
Is it possible to find points in a range of radius for example 10 for each point and add their "Value" and 'geometry' to GeoDataFrame so output would look like:
['ID','Value','geometry','value_of_point_in_range_1','geometry_of_point_in_range_1','value_of_point_in_range_2','geometry_of_point_in_range_2' etc.]
Before i was finding nearest neighbor for each and after that was checking if is it in range but i must find all of the points in radius and don't know what tool should i use.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管在您的示例中,输出将在结果框架中具有可预测的列数,但总体上这并不正确。因此,我将在数据框架中创建一个列,该列由表示附近点的索引/值/几何形状的列表组成。
在像您提供的小型数据集中,Python中的简单算术足以满足。但是对于大型数据集,您将需要使用空间树来查询附近的点。我建议这样使用Scipy的kdtree:
这会产生以下数据框架:
要验证结果,您可能会发现绘制结果有用:
Although in your example the output will have a predictable amount of columns in the resulting dataframe, this not true in general. Therefore I would instead create a column in the dataframe that consists of a lists denoting the index/value/geometry of the nearby points.
In a small dataset like you provided, simple arithmetics in python will suffice. But for large datasets you will want to use a spatial tree to query the nearby points. I suggest to use scipy's KDTree like this:
This yields the following dataframe:
To verify the results, you may find plotting the result usefull: