Skip to content

Commit

Permalink
Merge pull request #346 from ImperialCollegeLondon/osmnx_bug
Browse files Browse the repository at this point in the history
osmnx bug
  • Loading branch information
barneydobson authored Nov 29, 2024
2 parents 446fd2b + ff5d059 commit ad55635
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/swmmanywhere/prepare_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand All @@ -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,
Expand Down

0 comments on commit ad55635

Please sign in to comment.