跳转到主要内容

Xarray的Google Earth Engine扩展。

项目描述

Xee: Xarray + Google Earth Engine

Xee Logo

Google Earth Engine 的 Xarray 扩展。

image image Conda Recipe image Conda Downloads

如何使用

使用 pip 安装

pip install --upgrade xee

使用 conda 安装

conda install -c conda-forge xee

然后,验证 Earth Engine

earthengine authenticate --quiet

现在,在您的 Python 环境中,执行以下导入

import ee
import xarray

接下来,使用高容量 API 初始化 EE 客户端

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

通过指定 Xarray 引擎为 'ee' 打开任何 Earth Engine ImageCollection

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

打开特定投影下的所有波段(不是 Xee 默认的)

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

打开 ImageCollection(可能包含 EE 方面的过滤或处理)

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)

打开具有特定 EE 投影或几何形状的 ImageCollection

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
)

将多个 ImageCollections 打开到一个 xarray.Dataset 中,所有都具有相同的投影

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

通过传递给 ImageCollection 来打开单个 Image

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

打开任何 Earth Engine ImageCollection 以匹配现有的转换

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]
    ),
)

有关更多用法和集成,请参阅示例文档

如何运行集成测试

Xee 集成测试仅在 Xee 分支上通过(没有分支)。在发送 PR 之前,请在本地运行集成测试。要本地运行测试,请使用 earthengine authenticate 进行验证并运行以下命令

USE_ADC_CREDENTIALS=1 python -m unittest xee/ext_integration_test.py

许可证

这不是一个官方的 Google 产品。

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://apache.ac.cn/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.

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

xee-0.0.15.tar.gz (56.7 kB 查看散列)

上传

构建分布

xee-0.0.15-py3-none-any.whl (30.2 kB 查看散列)

上传 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面