GeoscienceAustralia / dea-notebooks

Repository for Digital Earth Australia Jupyter Notebooks: tools and workflows for geospatial analysis with Open Data Cube and Xarray
https://docs.dea.ga.gov.au/notebooks/
Apache License 2.0
441 stars 128 forks source link

Cannot import name 'write_geotiff' from 'datacube.helpers' #1060

Closed dehartmann closed 1 year ago

dehartmann commented 1 year ago

I downloaded the dea-notebooks repository imported it with the path: import sys sys.path.append('/path/dea-notebooks/Scripts/')

When importing the xr_rasterize function: from dea_spatialtools import xr_rasterize

I get the following error:


ImportError Traceback (most recent call last) Cell In[50], line 19 17 import sys 18 sys.path.append('C:/Users/hart_dd/Documents/Internship/Programs/dea-notebooks/dea-notebooks/Scripts/') # replace with the actual path ---> 19 from dea_spatialtools import xr_rasterize 20 import matplotlib.pyplot as plt 21 import matplotlib.colors

File C:\Users/hart_dd/Documents/Internship/Programs/dea-notebooks/dea-notebooks/Scripts\dea_spatialtools.py:44 42 from skimage.measure import find_contours 43 from shapely.geometry import LineString, MultiLineString, shape ---> 44 from datacube.helpers import write_geotiff 45 from datacube.utils.geometry import CRS, Geometry 48 def xr_vectorize(da, 49 attribute_col='attribute', 50 transform=None, (...) 53 export_shp=False, 54 **rasterio_kwargs):

ImportError: cannot import name 'write_geotiff' from 'datacube.helpers' (C:\Users\hart_dd\AppData\Local\miniconda3\envs\ice\Lib\site-packages\datacube\helpers.py)

Is it because write_geotiff is depreciated in the datacube version 1.8? I tried downgrading datacube to 1.7, but then I need to downgrade Python also to 3.8.

dehartmann commented 1 year ago

I solved it by downloading the stable repository.

robbibt commented 1 year ago

Hi @DEHartmann, yep, this looks like you were using an older version of DEA Notebooks. I recommend using Git to access the repo, something like this to make sure you have the latest version:

git clone https://github.com/GeoscienceAustralia/dea-notebooks.git
git checkout stable
git pull