Converting Earth Engine images to an Xarray Dataset
This notebook demonstrates how to convert Earth Engine images to an Xarray Dataset using xee.
# !pip install -U geemap
import ee
import geemap
geemap.ee_initialize()
Opening the ERA5-Land hourly dataset in Earth Engine and converting it to an Xarray Dataset. This is a huge dataset and it may take a minute or two to load. Please be patient.
ds = geemap.ee_to_xarray('ECMWF/ERA5_LAND/HOURLY', n_images=100)
ds
Open all bands in a specific projection and spatial resolution. Similarly, it may take a minute or two to load.
ds = geemap.ee_to_xarray('ECMWF/ERA5_LAND/HOURLY', crs='EPSG:4326', scale=0.25, n_images=100)
ds
Open an ImageCollection (maybe, with EE-side filtering or processing):
dataset = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate('1992-10-05', '1993-03-31')
ds = geemap.ee_to_xarray(dataset, crs='EPSG:4326', scale=0.25)
ds
Open an ImageCollection with a specific EE projection or geometry:
dataset = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate('1992-10-05', '1993-03-31')
geometry = ee.Geometry.Rectangle(113.33, -43.63, 153.56, -10.66)
ds = geemap.ee_to_xarray(
dataset,
projection=dataset.first().select(0).projection(),
geometry=geometry
)
ds
Opening a single image:
image = ee.Image("LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318")
ds = geemap.ee_to_xarray(image)
ds
Open multiple ImageCollections into one xarray.Dataset, all with the same projection. This one may take a few minutes to load.
ds = geemap.ee_to_xarray(
dataset=['ECMWF/ERA5_LAND/HOURLY', 'NASA/GDDP-CMIP6'],
n_images=100,
crs='EPSG:4326',
scale=0.25
)
ds