【发布时间】:2020-09-15 05:50:29
【问题描述】:
Here 介绍了如何使用 R-Tree 提升空间交叉点查询。 Here @JHuw 提供了使用 R-Tree 分别计算点到点和线的最近距离的方法。尽管如此,我还没有找到使用 R-Tree 提高从点到多边形的距离查询的解决方案。我遵循了上面提到的那些示例,但仍然没有弄清楚如何在从点到多边形的最近距离查询中实现 R-Tree。有人可以帮我解决这个问题吗?非常感激。下面我以南美洲和 GeoPandas 中的部分城市为例:
# Import libraries
import geopandas as gpd
import matplotlib.pyplot as plt
# Load data from GeoPandas
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
cities = gpd.read_file(gpd.datasets.get_path('naturalearth_cities'))
south_america = world[world.continent == 'South America']
city_sub = cities[cities.index < 20]
# Plot
ax= south_america.boundary.plot()
city_sub.plot(ax=ax)
# Nearest distance from point (city_sub) to polygon (south_america) using R-Tree
# "To be finished..."
【问题讨论】: