Skip to main content

A Google Earth Engine extension for Xarray.

Project description

Xee: Xarray + Google Earth Engine

Xee Logo

An Xarray extension for Google Earth Engine.

image image Conda Recipe image Conda Downloads

How to use

Install with pip:

pip install --upgrade xee

Install with conda:

conda install -c conda-forge xee

Then, authenticate Earth Engine:

earthengine authenticate --quiet

Now, in your Python environment, make the following imports:

import ee
import xarray

Next, specify your EE-registered cloud project ID and initialize the EE client with the high volume API:

ee.Initialize(
    project='my-project-id',
    opt_url='https://earthengine-highvolume.googleapis.com')

Open any Earth Engine ImageCollection by specifying the Xarray engine as 'ee':

ds = xarray.open_dataset('ee://ECMWF/ERA5_LAND/HOURLY', engine='ee')

Open all bands in a specific projection (not the Xee default):

ds = xarray.open_dataset('ee://ECMWF/ERA5_LAND/HOURLY', engine='ee',
                         crs='EPSG:4326', scale=0.25)

Open an ImageCollection (maybe, with EE-side filtering or processing):

ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate(
    '1992-10-05', '1993-03-31')
ds = xarray.open_dataset(ic, engine='ee', crs='EPSG:4326', scale=0.25)

Open an ImageCollection with a specific EE projection or geometry:

ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate(
    '1992-10-05', '1993-03-31')
leg1 = ee.Geometry.Rectangle(113.33, -43.63, 153.56, -10.66)
ds = xarray.open_dataset(
    ic,
    engine='ee',
    projection=ic.first().select(0).projection(),
    geometry=leg1
)

Open multiple ImageCollections into one xarray.Dataset, all with the same projection:

ds = xarray.open_mfdataset(
    ['ee://ECMWF/ERA5_LAND/HOURLY', 'ee://NASA/GDDP-CMIP6'],
    engine='ee', crs='EPSG:4326', scale=0.25)

Open a single Image by passing it to an ImageCollection:

i = ee.ImageCollection(ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318'))
ds = xarray.open_dataset(i, engine='ee')

Open any Earth Engine ImageCollection to match an existing transform:

raster = rioxarray.open_rasterio(...) # assume crs + transform is set
ds = xr.open_dataset(
    'ee://ECMWF/ERA5_LAND/HOURLY',
    engine='ee',
    geometry=tuple(raster.rio.bounds()), # must be in EPSG:4326
    projection=ee.Projection(
        crs=str(raster.rio.crs), transform=raster.rio.transform()[:6]
    ),
)

See examples or docs for more uses and integrations.

Getting help

If you encounter issues using Xee, you can:

  1. Open a new or add to an existing Xee discussion topic
  2. Open an Xee issue. To increase the likelihood of the issue being resolved, use this template Colab notebook to create a reproducible script.

How to run integration tests

The Xee integration tests only pass on Xee branches (no forks). Please run the integration tests locally before sending a PR. To run the tests locally, authenticate using earthengine authenticate and run the following:

python -m unittest xee/ext_integration_test.py

or

python -m pytest xee/ext_integration_test.py

License

This is not an official Google product.

Copyright 2023 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xee-0.0.24.tar.gz (421.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xee-0.0.24-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file xee-0.0.24.tar.gz.

File metadata

  • Download URL: xee-0.0.24.tar.gz
  • Upload date:
  • Size: 421.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xee-0.0.24.tar.gz
Algorithm Hash digest
SHA256 93ff9719527a5a9fea43b6e8ee439ebc6172edbcec7d2c1f677a7deecc0e90de
MD5 b7363d48bfe15c04370b4faa534a800c
BLAKE2b-256 77d87b2a591bda24e3b734ed50605c188f7b7eeb1b17d8d58c8a0b6ae6a0dc9e

See more details on using hashes here.

File details

Details for the file xee-0.0.24-py3-none-any.whl.

File metadata

  • Download URL: xee-0.0.24-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xee-0.0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 8f6fe58f04f22990e029291caa132a8836df8eeb047a6b636bb4b2cce35f413a
MD5 0b34648fa3f98308b857ffc56fa7370c
BLAKE2b-256 d566e8db0175e49b8d34d02e04ec57c36731ac4c126a1eb421f7e93aa1b1f4a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page