Update `geemap.ee_to_xarray()` method for updated `xee` syntax
bug
### Environment Information
```python
import geemap
geemap.Report()
```
```
--------------------------------------------------------------------------------
Date: Wed May 13 16:33:03 2026 UTC
OS : Darwin (macOS 26.4.1)
CPU(s) : 10
Machine : arm64
Architecture : 64bit
RAM : 32.0 GiB
Environment : Python
File system : apfs
Python 3.14.4 | packaged by conda-forge | (main, Apr 8 2026, 02:33:53)
[Clang 20.1.8 ]
geemap : 0.37.1
ee : 1.7.26
ipyleaflet : 0.20.0
folium : 0.20.0
jupyterlab : 4.5.6
notebook : 7.5.5
ipyevents : 2.0.4
geopandas : 1.1.3
--------------------------------------------------------------------------------
```
Additional package information:
```python
print(f'xee version: {xee.__version__}')
print(f'xarray version: {xr.__version__}')
```
```
xee version: 0.1.0
xarray version: 2026.4.0
```
### Description
When I try to follow along with the `geemap` tutorial for the [`ee_to_xarray()` method](https://geemap.org/notebooks/140_ee_to_xarray/), I am not able to pass in a `scale` parameter without encountering an error. I believe that this is because [breaking changes were introduced](https://xee.readthedocs.io/en/latest/migration-guide-v0.1.0.html) in the `v0.1.0` `xee` update, where the `scale` parameter is handled much differently than it was before.
The simple fix in this case would be to downgrade my version of `xee` in my `conda` environment. However, since the syntax for `xee` will be different moving forward, would it be possible to update the `ee_to_xarray()` method to align with the `xee` migration guidelines?
### What I Did
```python
import ee
import geemap
geemap.ee_initialize()
ds = geemap.ee_to_xarray(
'ECMWF/ERA5_LAND/HOURLY',
crs='EPSG:4326',
scale=0.1,
n_images=100,
)
```
And I see the error:
```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
[/tmp/ipykernel_22232/1079747063.py](https://localhost:8080/#) in <cell line: 0>()
----> 1 ds = geemap.ee_to_xarray(
2 'ECMWF/ERA5_LAND/HOURLY',
3 crs='EPSG:4326',
4 scale=0.1,
5 n_images=100,
1 frames
[/usr/local/lib/python3.12/dist-packages/xarray/backends/api.py](https://localhost:8080/#) in open_dataset(filename_or_obj, engine, chunks, cache, decode_cf, mask_and_scale, decode_times, decode_timedelta, use_cftime, concat_characters, decode_coords, drop_variables, create_default_indexes, inline_array, chunked_array_type, from_array_kwargs, backend_kwargs, **kwargs)
604
605 overwrite_encoded_chunks = kwargs.pop("overwrite_encoded_chunks", None)
--> 606 backend_ds = backend.open_dataset(
607 filename_or_obj,
608 drop_variables=drop_variables,
TypeError: EarthEngineBackendEntrypoint.open_dataset() got an unexpected keyword argument 'scale'
```
To try and replicate the previous functionality of the `geemap.ee_to_xarray()` method, I had to use the [updated `xee` syntax](https://xee.readthedocs.io/en/latest/migration-guide-v0.1.0.html#option-1-match-source-grid-recommended-for-simplicity) that allows me to pass in a `scale` parameter through a `grid_params` dict, though this meant not using `geemap`.
```python
import ee
import geemap
# !pip install xee
import xee
import xarray
geemap.ee_initialize()
ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY')
grid_params = xee.helpers.extract_grid_params(ic)
# grid_params: {'crs': 'EPSG:4326', 'crs_transform': (0.1, 0, -180.05, 0, -0.1, 90.05), 'shape_2d': (3601, 1801)}
ds = xr.open_dataset(
ic,
engine='ee',
n_images=100,
**grid_params,
)
```
关闭于 2026-05-14 3 条评论