DariaTan / ArableLand2

1 stars 0 forks source link

Data location #3

Open vjugor1 opened 1 year ago

vjugor1 commented 1 year ago

Seems like your Geo_data is assumed to be located outside of the crop directory with code. Judging from this error trace.

I guess we should amend the code to retrieve data from the . folder, i.e., /crop, if we are talking about container

---------------------------------------------------------------------------
CPLE_OpenFailedError                      Traceback (most recent call last)
File rasterio/_base.pyx:261, in rasterio._base.DatasetBase.__init__()

File rasterio/_shim.pyx:78, in rasterio._shim.open_dataset()

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

CPLE_OpenFailedError: ../../Geo_data/Crop_Eurasia/Elv.tif: No such file or directory

During handling of the above exception, another exception occurred:

RasterioIOError                           Traceback (most recent call last)
Cell In[4], line 3
      1 import sys, os
      2 sys.path.append('../src/')
----> 3 import load_data, plotting, utils
      5 sys.path.append('../src/models/')
      6 import crop_classifier

File /crop/notebooks/../src/plotting.py:32
     24 my_gradient = LinearSegmentedColormap.from_list('my_gradient', (
     25                                             (0.000, (0.898, 0.000, 0.000)),
     26                                             (0.250, (0.965, 0.604, 0.604)),
     27                                             (0.500, (1.000, 1.000, 1.000)),
     28                                             (0.750, (0.627, 0.961, 0.639)),
     29                                             (1.000, (0.165, 0.494, 0.098))))
     31 # Shape f source raster
---> 32 Elv = load_data.elevation('../../Geo_data/')
     33 h = Elv.shape[0]
     34 w = Elv.shape[1]

File /crop/notebooks/../src/load_data.py:26, in elevation(path)
     13 def elevation(path):
     14     """Collects elevation features
     15 
     16     Parameters:
   (...)
     24             Elevation values of objects
     25     """
---> 26     data = rasterio.open(path + 'Crop_Eurasia/Elv.tif')
     27     Elv = data.read(1)
     28     data = None

File /opt/conda/envs/al2/lib/python3.10/site-packages/rasterio/env.py:437, in ensure_env_with_credentials.<locals>.wrapper(*args, **kwds)
    434     session = DummySession()
    436 with env_ctor(session=session):
--> 437     return f(*args, **kwds)

File /opt/conda/envs/al2/lib/python3.10/site-packages/rasterio/__init__.py:220, in open(fp, mode, driver, width, height, count, crs, transform, dtype, nodata, sharing, **kwargs)
    216 # Create dataset instances and pass the given env, which will
    217 # be taken over by the dataset's context manager if it is not
    218 # None.
    219 if mode == 'r':
--> 220     s = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
    221 elif mode == "r+":
    222     s = get_writer_for_path(path, driver=driver)(
    223         path, mode, driver=driver, sharing=sharing, **kwargs
    224     )

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

RasterioIOError: ../../Geo_data/Crop_Eurasia/Elv.tif: No such file or directory
vjugor1 commented 1 year ago

@DariaTan