Deltares / ra2ce

RA2CE helps to quantify resilience of critical infrastructure networks, prioritize interventions and adaptation measures and select the most appropriate action perspective to increase resilience considering future conditions.
https://deltares.github.io/ra2ce/
Other
9 stars 2 forks source link

Binder environment error on `example_optimal_route_origin_destination.ipynb` #440

Closed mjevanmarle closed 2 months ago

mjevanmarle commented 2 months ago

Ra2ce version checks

Reproducible example

In the example_optimal_route_origin_destination.ipynb notebook example on optimal route origin destination at [14] you get an error in the binder environment:

hazard_folder = root_dir / "static" / "hazard" # find the hazard folder where you locate your flood map
hazard_map = hazard_folder / "max_flood_depth.tif" # set the location of the hazard map
​
# Open the TIF file using rasterio:
with rasterio.open(hazard_map) as src:
    # Read the TIF file as a numpy array
    tif_array = src.read(1)  # Change the band index (1) if necessary
​
plt.figure(figsize=(10, 10))
plt.imshow(tif_array, cmap='Blues')  # Change the colormap if desired
plt.colorbar(label='Pixel Values')
plt.title('Flood map')
plt.show()
2024-05-23 11:49:13 AM - [__init__.py:304] - rasterio._env - INFO - GDAL signalled an error: err_no=4, msg='.\\data\\optimal_routes_analysis_with_hazard/static/hazard/max_flood_depth.tif: No such file or directory'
---------------------------------------------------------------------------
CPLE_OpenFailedError                      Traceback (most recent call last)
File rasterio/_base.pyx:310, in rasterio._base.DatasetBase.__init__()

File rasterio/_base.pyx:221, in rasterio._base.open_dataset()

File rasterio/_err.pyx:221, in rasterio._err.exc_wrap_pointer()

CPLE_OpenFailedError: .\data\optimal_routes_analysis_with_hazard/static/hazard/max_flood_depth.tif: No such file or directory

During handling of the above exception, another exception occurred:

RasterioIOError                           Traceback (most recent call last)
Cell In[14], line 5
      2 hazard_map = hazard_folder / "max_flood_depth.tif" # set the location of the hazard map
      4 # Open the TIF file using rasterio
----> 5 with rasterio.open(hazard_map) as src:
      6     # Read the TIF file as a numpy array
      7     tif_array = src.read(1)  # Change the band index (1) if necessary
      9 plt.figure(figsize=(10, 10))

File /srv/conda/envs/notebook/lib/python3.10/site-packages/rasterio/env.py:451, in ensure_env_with_credentials.<locals>.wrapper(*args, **kwds)
    448     session = DummySession()
    450 with env_ctor(session=session):
--> 451     return f(*args, **kwds)

File /srv/conda/envs/notebook/lib/python3.10/site-packages/rasterio/__init__.py:304, in open(fp, mode, driver, width, height, count, crs, transform, dtype, nodata, sharing, **kwargs)
    301 path = _parse_path(raw_dataset_path)
    303 if mode == "r":
--> 304     dataset = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
    305 elif mode == "r+":
    306     dataset = get_writer_for_path(path, driver=driver)(
    307         path, mode, driver=driver, sharing=sharing, **kwargs
    308     )

File rasterio/_base.pyx:312, in rasterio._base.DatasetBase.__init__()

RasterioIOError: .\data\optimal_routes_analysis_with_hazard/static/hazard/max_flood_depth.tif: No such file or directory

Current behaviour

Error message in binder environment

Desired behaviour

No error

Additional context

No response

LiekeMeijer commented 2 months ago

I cannot reproduce this issue locally. This leads me to think that it is an issue in the Binder environment. In the Binder environment I indeed get the same issue. Maybe @Carsopre you can check whether there is something wrong in the Binder environment?