opengeos / leafmap

A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment
https://leafmap.org
MIT License
3.22k stars 386 forks source link

Read netcdf from variable #271

Closed mn5hk closed 2 years ago

mn5hk commented 2 years ago

Description

I am trying to read netCDF into leafmap. While it works very well with the "*.nc" file, the current version does not support reading netCDFs (xarray files) from a variable.

Implementing the code below in the current version results in the following error: AttributeError: 'Dataset' object has no attribute 'startswith'

Source code

m.add_netcdf(netCDF_variable, 
            variables = ['variable_name'],
            palette = 'coolwarm',
            shift_lon = True)
giswqs commented 2 years ago

Leafmap relies on localtileserve to display raster data. Localtileserver can't display xarrays directly. The input needs to be physical files, such as GeoTIFFs. You need to convert xarrays to GeoTIFFs to be displayed on the map.

https://geemap.org/notebooks/105_netcdf/