140 ee to xarray
Converting Earth Engine images to an Xarray Dataset
This notebook demonstrates how to convert Earth Engine images to an Xarray Dataset using xee.
In [ ]:
Copied!
# !pip install -U geemap
# !pip install -U geemap
In [ ]:
Copied!
import ee
import geemap
import ee
import geemap
In [ ]:
Copied!
geemap.ee_initialize()
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.
In [ ]:
Copied!
ds = geemap.ee_to_xarray("ECMWF/ERA5_LAND/HOURLY", n_images=100)
ds
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.
In [ ]:
Copied!
ds = geemap.ee_to_xarray(
"ECMWF/ERA5_LAND/HOURLY", crs="EPSG:4326", scale=0.25, n_images=100
)
ds
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):
In [ ]:
Copied!
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
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:
In [ ]:
Copied!
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
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:
In [ ]:
Copied!
image = ee.Image("LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318")
ds = geemap.ee_to_xarray(image)
ds
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.
In [ ]:
Copied!
ds = geemap.ee_to_xarray(
dataset=["ECMWF/ERA5_LAND/HOURLY", "NASA/GDDP-CMIP6"],
n_images=100,
crs="EPSG:4326",
scale=0.25,
)
ds
ds = geemap.ee_to_xarray(
dataset=["ECMWF/ERA5_LAND/HOURLY", "NASA/GDDP-CMIP6"],
n_images=100,
crs="EPSG:4326",
scale=0.25,
)
ds