0

I'm trying some code to get the building footprints of Barcelona:

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)

When I run the code it yields the following error message:

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

I've tried updating the OSMnx version but it seems not to be the problem. How can I solve this issue?

Rodrigo Vargas
  • 273
  • 3
  • 17

1 Answers1

0

The solution is posted in the following github repository:

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

You should change the footprints.py file with the updated code. To do so you can: -open the file in the osmnx package paste, delete its contents and copy the updated ones,

-or create a new file and then replace it in the osmnx package paste.

Rodrigo Vargas
  • 273
  • 3
  • 17