我正在使用一个从Dask计算NDVI的示例代码。代码的链接如下所示。NDVI计算代码
在使用以下代码块创建xarray数据集时,
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我得到以下导入错误
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'我已经尽力而为,找不到帮助。如果有人能帮助我识别这个导入错误的原因,那就太好了。
发布于 2019-05-04 01:56:21
您可能需要考虑使用conda包管理器,它可以以一致的方式处理Python包(如Xarray )以及二进制包(如GDAL和rasterio )。
发布于 2019-11-07 11:54:07
当我得到那个错误时,通常是包依赖关系不同步的时候。一个conda update --all为我修复了它。
https://stackoverflow.com/questions/55919651
复制相似问题