I am using an example code for NDVI computation from Dask. The link to the code is as follows. code for computing NDVI

while creating xarray datasets using the below block of code,

import xarray as xr
red = xr.open_rasterio('red.tif', chunks={'band': 1, 'x': 1024, 'y': 1024})
nir = xr.open_rasterio('nir.tif', chunks={'band': 1, 'x': 1024, 'y': 1024})
nir

I am getting the following import error

ImportError                               Traceback (most recent call last)
<ipython-input-42-a3df5765cb4e> in <module>
  1 import xarray as xr
----> 2 red = xr.open_rasterio('red.tif', chunks={'band': 1, 'x': 1024, 'y': 1024})
  3 nir = xr.open_rasterio('nir.tif', chunks={'band': 1, 'x': 1024, 'y': 1024})
  4 nir
/usr/local/lib/python3.5/dist-packages/xarray/backends/rasterio_.py in open_rasterio(filename, parse_coordinates, chunks, cache, lock)
213     """
214     import rasterio
--> 215     from rasterio.vrt import WarpedVRT
216     vrt_params = None
217     if isinstance(filename, rasterio.io.DatasetReader):
ImportError: No module named 'rasterio.vrt'

I have searched to my best and couldnot find help. It would be great if anyone can help me to identify the cause of this import error.

1 Answers

0
MRocklin On

You may want to consider using the conda package manager, which can handle both Python packages like Xarray as well as binary packages like GDAL and rasterio in a consistent manner.