gboeing / osmnx

OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap.
https://osmnx.readthedocs.io
MIT License
4.89k stars 827 forks source link

FutureWarning: The 'unary_union' attribute is deprecated #1178

Closed EwoutH closed 5 months ago

EwoutH commented 5 months ago

Contributing guidelines

Documentation

Existing issues

What operating system and Python version are you using?

Python 3.12

What OSMnx version are you using?

2.0.0beta0

Environment packages and versions

Python 3.12
OSMnx 2.0.0beta0
Shapely 2.0.4
Geopandas 1.0.0a1

How did you install OSMnx?

Other (describe below)

Problem description

When using consolidate_intersections(), the following warning pops up:

osmnx\simplification.py:668: FutureWarning: The 'unary_union' attribute is deprecated, use the 'union_all()' method instead. subcluster_centroid = node_points.loc[idx].unary_union.centroid

Looks like this is the source:

https://github.com/gboeing/osmnx/blob/a99fc4d7dd9ee13b256347af7cdcb58d214e8915/osmnx/simplification.py#L668

I'm running Geopandas 1.0.0a1, that might be the source of it. So just a head up.

Complete minimal reproducible example

Run consolidate_intersections() in the environment listed above.
EwoutH commented 5 months ago

Found the source, it's https://github.com/geopandas/geopandas/pull/3007.

unary_union should not be an attribute. There is no good way of deprecating an attribute and turning it into a method, so as discussed in person with jorisvandenbossche, it may be the best to have a new method and deprecate an attribute. We can have a longer deprecation here, unary_union does not need to be removed in 1.0.

CC @martinfleis.

EwoutH commented 5 months ago

I'm confused a bit, because unary_union also is imported from shapely.ops.

https://github.com/gboeing/osmnx/blob/a99fc4d7dd9ee13b256347af7cdcb58d214e8915/osmnx/features.py#L32

gboeing commented 5 months ago

I'm confused a bit, because unary_union also is imported from shapely.ops.

https://github.com/gboeing/osmnx/blob/a99fc4d7dd9ee13b256347af7cdcb58d214e8915/osmnx/features.py#L32

This unary_union is a function from shapely, not the attribute of a GeoSeries.

gboeing commented 5 months ago

See https://github.com/gboeing/osmnx/issues/1123#issuecomment-2135731519