diff --git a/src/swmmanywhere/prepare_data.py b/src/swmmanywhere/prepare_data.py index e98359a0..5a19cbda 100644 --- a/src/swmmanywhere/prepare_data.py +++ b/src/swmmanywhere/prepare_data.py @@ -19,6 +19,7 @@ import rioxarray.merge as rxr_merge import xarray as xr from geopy.geocoders import Nominatim +from packaging.version import Version from pyarrow import RecordBatchReader from pyarrow.compute import field from pyarrow.dataset import dataset @@ -153,8 +154,9 @@ def download_street( nx.MultiDiGraph: Street network with type drive and ``truncate_by_edge set`` to True. """ - west, south, east, north = bbox - bbox = (north, south, east, west) # not sure why osmnx uses this order + if Version(ox.__version__) < Version("2.0.0b1"): + west, south, east, north = bbox + bbox = (north, south, east, west) graph = ox.graph_from_bbox( bbox=bbox, network_type=network_type, truncate_by_edge=True ) @@ -172,10 +174,12 @@ def download_river(bbox: tuple[float, float, float, float]) -> nx.MultiDiGraph: nx.MultiDiGraph: River network with type waterway and ``truncate_by_edge set`` to True. """ - west, south, east, north = bbox try: + if Version(ox.__version__) < Version("2.0.0b1"): + west, south, east, north = bbox + bbox = (north, south, east, west) graph = ox.graph_from_bbox( - bbox=(north, south, east, west), + bbox=bbox, truncate_by_edge=True, custom_filter='["waterway"]', retain_all=True,