Skip to content

incorrect coordinate when export ERA5L #171

Description

@kongdd

I faced with a strange issue. It seems that lon and lat is confused (lon becomes lat, lat becomes lon).

import ee
import xee
import xarray as xr
import xarray

# ee.Initialize()
ee.Initialize(opt_url='https://earthengine-highvolume.googleapis.com')


def ee_col_download_year(region, col_id='ECMWF/ERA5_LAND/HOURLY',
                         year=2022, fout="a.nc"):
    # fout = prefix + col_id.replace("/", "_") + "_" + str(year) + ".nc"
    
    ic = (ee.ImageCollection(col_id)
          .filter(ee.Filter.calendarRange(year, year, 'year'))
          .select(['surface_net_solar_radiation'])
          .limit(10)
          )
    print(fout)
    print(ic.size().getInfo())

    ds = xarray.open_dataset(
        ic,
        engine='ee',
        projection=ic.first().select(0).projection(),
        geometry=region
    )
    ds.to_netcdf(fout)
    ds

region = ee.Geometry.Rectangle(108.5, 28.75, 116.25, 33.5)
ee_col_download_year(region, year=2024, fout="test.nc")

Inspect in R:

library(terra)
ra = rast("./test.nc")
plot(ra[[1]])

image

netCDF4 is installed (v1.7.1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions