拓扑错误: 无法执行操作'GEOSDifference_r'



我正在尝试一些代码来获取巴塞罗那的建筑足迹:

import osmnx as ox
import matplotlib.pyplot as plt
%matplotlib inline
place_name = "Barcelona, Barcelona, Catalonia, Spain"
graph = ox.graph_from_place(place_name)
buildings = ox.footprints_from_place(place_name)

当我运行代码时,它会产生以下错误消息:

TopologicalError: The operation 'GEOSDifference_r' could not be performed. Likely cause is invalidity of the geometry <shapely.geometry.polygon.Polygon object at 0x00000262079B6550>

我尝试更新OSMnx版本,但这似乎不是问题。 如何解决此问题?

该解决方案发布在以下 github 存储库中:

https://github.com/gboeing/osmnx/blob/5176d4a2f86fd2adaf523d3d9bd0bed9b9b1d6ec/osmnx/footprints.py

应使用更新的代码更改footprints.py文件。 为此,您可以: - 打开OSMNX软件包粘贴中的文件,删除其内容并复制更新的内容,

-或者创建一个新文件,然后在OSMNX软件包粘贴中替换它。

最新更新