【问题标题】:Finding distance to nearest school from buildings with Geopandas使用 Geopandas 从建筑物中查找到最近学校的距离
【发布时间】:2020-10-06 02:29:29
【问题描述】:

我想计算最近学校与特定地理区域建筑物的距离,然后对距离值进行分类(例如 0-100、100-200 等) 使用的数据源是 OpenStreetMap (OSM) .

首先,我将建筑物和学校数据存储在两个单独的地理数据框中,并尝试采用 (Calculate Distance to Nearest Feature with Geopandas) 的解决方案。但我遇到了一些错误。

这个问题是不同的,因为两个地理数据帧都包含多种几何类型,即(OSM 中的节点)和多边形(OSM 中的方式)。 p>

【问题讨论】:

  • 请添加您的代码,您尝试了什么,并分享错误信息。

标签: python openstreetmap geopandas


【解决方案1】:

假设您有 buiding_df 和 school_df 分别是用于构建学校的两个数据框。现在您可以使用以下代码计算最近学校与特定区域建筑物的距离,

def nearest_school(building_df, school_df):
    return school_df.distance(building_df).min()

buildings_utm['nearest_school_distance'] = building_df.geometry.apply(nearest_school, args=(school_df,))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-13
    • 2020-05-10
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 2021-07-20
    相关资源
    最近更新 更多