pythongeopandasosmnxoserror

I have an error using OSMNX: OS error when using ox.graph_from_place


I recently reinstalled OSMNX using pip and now I get a strange OS error I honestly have never seen before and google did not help me as well...

Here is a code excerpt with the error. I tried to restart the environment and also tried another VE to run it but the same error appears. It does actually not seem to be some native bug of OSMNX and seems to go to geopandas or shapely.

And no, I have never encountered anything similar and I am using anaconda, being the superuser (win10) of this machine with all rights.

OSError                                   Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_18096\802543517.py in <module>
      6 
      7 # download the street network
----> 8 G = ox.graph_from_place('Berlin', network_type = 'drive', simplify=False)

~\anaconda3\lib\site-packages\osmnx\graph.py in graph_from_place(query, network_type, simplify, retain_all, truncate_by_edge, which_result, buffer_dist, clean_periphery, custom_filter)
    345 
    346     # extract the geometry from the GeoDataFrame to use in API query
--> 347     polygon = gdf_place["geometry"].unary_union
    348     utils.log("Constructed place geometry polygon(s) to query API")
    349 

~\anaconda3\lib\site-packages\geopandas\base.py in unary_union(self)
    726         POLYGON ((0 1, 0 2, 2 2, 2 0, 1 0, 0 0, 0 1))
    727         
--> 728         return self.geometry.values.unary_union()
    729 
    730     #

~\anaconda3\lib\site-packages\geopandas\array.py in unary_union(self)
    636 
    637     def unary_union(self):
--> 638         return vectorized.unary_union(self.data)
    639 
    640     #

~\anaconda3\lib\site-packages\geopandas\_vectorized.py in unary_union(data)
    909         data = [g for g in data if g is not None]
    910         if data:
--> 911             return shapely.ops.unary_union(data)
    912         else:
    913             return None

~\anaconda3\lib\site-packages\shapely\ops.py in unary_union(self, geoms)
    159             subs[i] = g._geom
    160         collection = lgeos.GEOSGeom_createCollection(6, subs, L)
--> 161         return geom_factory(lgeos.methods['unary_union'](collection))
    162 
    163 operator = CollectionOperator()

OSError: exception: access violation writing 0x0000000000001101

Solution

  • I recently reinstalled OSMNX using pip

    You did not follow the OSMnx installation instructions so this error is to be expected. Follow the documented instructions and it will resolve.