I am struggling to complete this task. I am trying OSMnx which can be used to download data from OSM above however I am getting an error when using its from_polygon feature when trying to download data. Also, I am not sure if this data will include Buildings data.

I load my shapefile into geopandas and can then view and interact with it

This is the code

Building_data = ox.graph_from_polygon(my_shapefile, network_type='all')

However, I am getting this error

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

EDIT: I managed to convert the shapefile into a shapely polygon and run the OSMnx script again,

from shapely.geometry import shape
import fiona
c = fiona.open('E:/shapefile.shp')
pol = c.next()
geom = shape(pol['geometry'])

import osmnx as ox
data = ox.graph_from_polygon(geom, network_type='all')

however, now I get this CRS error:

Invalid projection: +proj=utm +zone=80957 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs: (Internal Proj Error: proj_create: Error -35 (invalid UTM zone number)). 

It seems a shapely polygon has no CRS or the wrong CRS.

  • Your code snippet isn't reproducible (as the critical input file is missing). It will be easier to answer your question if you provide a minimal complete reproducible code snippet and the full error traceback.
    – gboeing
    Apr 16, 2021 at 0:04
  • UTM zones like this are EPSG UTM codes start with 326 or 327. 80957 is not understood.
    – wingnut
    Apr 22, 2021 at 5:45

1 Answer 1


I wasn't able to download buildings data from OSM with a polygon (shapefile) as the bounding box however I was able to using distance from a point with the following code:

import osmnx as ox 
import ast

point = 'point coordinates'
dist = 'distance in m'
buildings = ox.geometries.geometries_from_point(point, {'building': True}, dist=dist)

And convert to a geodataframe:

buildings_save = buildings.applymap(lambda x: str(x) if isinstance(x, list) else x)

Then I clip the buildings data to a boundary using geopandas:

import geopandas as gpd

boundary = gpd.read_file('C:/boundary.shp')
buildings_final = gpd.clip(buildings_save, boundary)

Plot the data to check:

import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize = (15,12))
buildings_final.plot(ax = ax, color = 'red', edgecolor = 'black',)
plt.title('Buildings Data')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.