gee-community/geemap

Issues getting netcdf_to_ee() to work

Closed this issue · 1 comments

Discussed in #2031

Originally posted by cjheitzig June 5, 2024
I am trying to use netcdf_to_ee() to convert Copernicus land use data into an ee.image for further processing. My code already is calculating zonal statistics on nighttime lights and GHSL population data as ee.images, so to have it in this format is quite useful.

I would totally use code like the below to download Copernicus land use data, but for some reason landuse data from 1992 is not available in the Google Earth Engine library, so I cannot do this. I am trying to download data for 1992 only. I would upload a compressed sample file, but the data is larger than the allotted 25MB, so instead I am linking above.

landcover = ee.ImageCollection("COPERNICUS/CORINE/V20/100m")

My issue is that when I run the below code, I receive the error "The netCDF file is not a regular longitude/latitude grid". Others have mentioned this issue (e.g. #1945) and it has supposedly been fixed, but it gives me the same error and does not import the netcdf as an ee.image. I am using geemaps Version: 0.32.1.

url1992     = ".../landuse1992.nc"   # Data downloaded from the CDS link above
nc_dataset = netCDF4.Dataset(url1992, 'r')
var_names = list(nc_dataset.variables.keys())
landuse1992 = geemap.netcdf_to_ee(nc_file=url1992, var_names=var_names, lat='lat', lon='lon')

When I use the example in the Geemap book, I note the following characteristics of the 'wind_global.nc' dataset (which I am able to convert to an ee.image):

Latitude dimensions: ('lat',)
Longitude dimensions: ('lon',)
Latitude data type: float64
Longitude data type: float64
Latitude shape: (181,)
Longitude shape: (360,)
Latitude max: 90.0
Latitude min: -90.0
Longitude max: 359.0
Longitude min: 0.0

With the Copernicus land use data in 1992, I note these characteristics:

Latitude dimensions: ('lat',)
Longitude dimensions: ('lon',)
Latitude data type: float64
Longitude data type: float64
Latitude shape: (64800,)
Longitude shape: (129600,)
Latitude max: 89.99861111111113
Latitude min: -89.99861111111112
Longitude max: 179.99861111111113
Longitude min: -179.9986111111111

I'm not sure what the issue is and would be grateful for any help. I simply don't know enough about this stuff to understand why my data does not work while 'wind_global.nc' works. I ultimately would like to use geemap.zonal_stats() to report zonal statistics of land use over 5km cells.

See answer in #2031