python - OSMnx:检索多个城市的建筑多边形
问题描述
我是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
有人能帮我吗?谢谢
解决方案
看起来 OSMnx 的footprints
模块没有正确处理或忽略复杂的(并且可能无效?)多面几何。请注意,我们正在努力用更强大、更健壮、更通用的模块替换footprints
和模块。同时,我相信您可以通过以下模块实现您的目标:pois
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)
推荐阅读
- linux - 为什么在 kali linux 上使用 find 命令时出现“权限被拒绝”错误流
- objective-c - firebase-dynamic-links - [33353:495188] 8.5.0[Firebase/Analytics][I-ACS023001]Deep Link 不包含有效的必需参数。"match_message"="No pre
- open3d - 有没有办法从 open3d 中的另一个 Visualizer 获取缩放属性
- python - 数据字段的映射
- node.js - 参数中的节点JS未定义变量
- android - 对我来说,添加 android:exported="true" 并不能解决问题
- ios - iOS - 将objective-c库项目导入SwiftUI项目
- sql - 使用 SQL 进行预订可用性检查
- asp.net-mvc - telerik MVC GridBoundColumn 创建我自己的 Bound 方法
- javascript - ChromeExtension + Tradingview 策略变更 - Javascript