OSMnx:检索多个城市的建筑多边形

2024-09-29 17:47:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我是osm的新手。 目前,我正在尝试使用python中的osmnx包检索多个城市的建筑多边形

代码:

place = "Kuala Lumpur, Malaysia"
graph = ox.footprints.footprints_from_place(place, footprint_type='building')

graph.head()

它很好用

但是,如果我想获得另一个状态,它将返回一个错误

(如果我想在国家级检索它,也会得到相同的结果——在本例中为-place=“Malaysia”)

place = "Selangor, Malaysia"
graph = ox.footprints.footprints_from_place(place, footprint_type='building')

graph.head()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-20-9e3439b6fc4c> in <module>()
      1 place = "Selangor, Malaysia"
----> 2 graph = ox.footprints.footprints_from_place(place, footprint_type='building')
      3 
      4 graph.head()

5 frames
/usr/local/lib/python3.6/dist-packages/shapely/geometry/multipolygon.py in geos_multipolygon_from_polygons(arg)
    175     # no implicit flattening.
    176     if isinstance(obs[0], MultiPolygon):
--> 177         raise ValueError("Sequences of multi-polygons are not valid arguments")
    178 
    179     exemplar = obs[0]

ValueError: Sequences of multi-polygons are not valid arguments

有人能帮我吗? 谢谢


Tags: infromtypeplaceheadgraphoxvalueerror
1条回答
网友
1楼 · 发布于 2024-09-29 17:47:47

看起来OSMnx的footprints模块没有正确处理或忽略复杂(可能是无效的?)多边形几何体。请注意are underwayfootprintspois模块替换为更强大、更健壮、更通用的geometries模块的努力。同时,我相信您可以通过以下pois模块实现您的目标:

import osmnx as ox
ox.config(use_cache=True, log_console=True)
place = 'Selangor, Malaysia'
gdf = ox.pois_from_place(place, tags={'building': True})
gdf.shape  # (47516, 390)

相关问题 更多 >

    热门问题