在投影 CRS 中计算距离
现在我们已经将埃菲尔铁塔的位置转换到一个投影坐标系,就可以计算它到其他点的距离了。
前一个练习得到的最终 s_eiffel_tower_projected(包含投影后的 Point)已提供,我们将其中的单个点提取到变量 eiffel_tower。另外,使用 WGS84 坐标的 restaurants 数据框也已加载。
本练习是课程的一部分
在 Python 中处理地理空间数据
练习说明
- 将
restaurants转换为与埃菲尔铁塔点相同的 CRS。本练习不要指定epsg关键字,而是使用.crs属性。 - 计算所有餐馆到埃菲尔铁塔的距离。
- 输出最小的距离。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Extract the single Point
eiffel_tower = s_eiffel_tower_projected[0]
# Ensure the restaurants use the same CRS
restaurants = restaurants.____
# The distance from each restaurant to the Eiffel Tower
dist_eiffel = ____
# The distance to the closest restaurant
print(____)