gee-community / geemap

A Python package for interactive geospatial analysis and visualization with Google Earth Engine.
https://geemap.org
MIT License
3.47k stars 1.09k forks source link

Netcdf to ee error #887

Closed Daniel-Trung-Nguyen closed 2 years ago

Daniel-Trung-Nguyen commented 2 years ago

I was running the "68_netcdf_to_ee" notebook and got this error message. Can you please help? Cheers, Daniel

did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'h5netcdf', 'scipy', 'pydap', 'zarr']. Consider explicitly selecting one of the installed engines via the engine parameter, or installing additional IO dependencies, see: http://xarray.pydata.org/en/stable/getting-started-guide/installing.html http://xarray.pydata.org/en/stable/user-guide/io.html

AttributeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_31820/917392944.py in 4 5 Map = geemap.Map() ----> 6 Map.addLayer(img, {'min':-20, 'max':25, 'palette':palette, 'opacity':0.6}, "u_wind") 7 Map

~\AppData\Local\ESRI\conda\envs\gee\lib\site-packages\geemap\geemap.py in add_ee_layer(self, ee_object, vis_params, name, shown, opacity) 1364 ): 1365 err_str = "\n\nThe image argument in 'addLayer' function must be an instance of one of ee.Image, ee.Geometry, ee.Feature or ee.FeatureCollection." -> 1366 raise AttributeError(err_str) 1367 1368 if (

AttributeError:

The image argument in 'addLayer' function must be an instance of one of ee.Image, ee.Geometry, ee.Feature or ee.FeatureCollection.

Daniel-Trung-Nguyen commented 2 years ago

Also, there seems to be a bug in the ee_export_image function: "local variable 'r' referenced before assignment"

  1 filename = 'soc_0-30.tif'

----> 2 geemap.ee_export_image(soc30, filename, scale=None, crs=None, region=None, file_per_band=False)

~\AppData\Local\ESRI\conda\envs\gee\lib\site-packages\geemap\common.py in ee_export_image(ee_object, filename, scale, crs, region, file_per_band) 1726 except Exception as e: 1727 print("An error occurred while downloading.") -> 1728 print(r.json()["error"]["message"]) 1729 return 1730

UnboundLocalError: local variable 'r' referenced before assignment

giswqs commented 2 years ago

Regarding the netcdf issue, you will need install xarray and netcdf4. Leafmap does not include netcdf4 as an in official dependency. The notebook example works fine on my end once the xarray and netcdf4 are installed.

conda install mamba -c conda-forge
mamba install xarray netcdf4 -c conda-forge

image

giswqs commented 2 years ago

Also, there seems to be a bug in the ee_export_image function: "local variable 'r' referenced before assignment"

Please provide complete source code that can reproduce the issue. The notebook example works fine on my end. https://geemap.org/notebooks/11_export_image/.

Open another issue as it is unrelated to netcdf here.