Skip to content

Commit

Permalink
Add basic handling for X,Y,band,time dimensions for transpose and rep… (
Browse files Browse the repository at this point in the history
#244)

* Add basic handling for X,Y,band,time dimensions for transpose and reprojection in the resample_spatial process

* Updated README to include the --recurse-submodules in the instructions to fetch process specs

* Updated resample_spatial to include a dummy align parameter, reworked N dimensional transpose support to keep the data.openeo functionality

* Run pre-commit to hopefully fix the tests

---------

Co-authored-by: Zvolenský Juraj <jzvolensky@eosao34.eurac.edu>
  • Loading branch information
jzvolensky and Zvolenský Juraj authored May 6, 2024
1 parent 5ab8aa6 commit ea996ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ A subset of process implementations with heavy or unstable dependencies are hidd
## Development environment
openeo-processes-dask requires poetry >1.2, see their [docs](https://python-poetry.org/docs/#installation) for installation instructions.

Clone the repository with `--recurse-submodules` to also fetch the process specs:
```
git clone --recurse-submodules git@github.com:Open-EO/openeo-processes-dask.git
```

To setup the python venv and install this project into it run:
```
poetry install --all-extras
Expand Down
12 changes: 9 additions & 3 deletions openeo_processes_dask/process_implementations/cubes/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def resample_spatial(
projection: Optional[Union[str, int]] = None,
resolution: int = 0,
method: str = "near",
align: str = "upper-left",
):
"""Resamples the spatial dimensions (x,y) of the data cube to a specified resolution and/or warps the data cube to the target projection. At least resolution or projection must be specified."""

Expand All @@ -50,13 +51,18 @@ def resample_spatial(
f"[{', '.join(resample_methods_list)}]"
)

# Re-order, this is specifically done for odc reproject
data_cp = data.transpose(
dims = list(data.dims)

known_dims = [
data.openeo.band_dims[0],
data.openeo.temporal_dims[0],
data.openeo.y_dim,
data.openeo.x_dim,
)
]

other_dims = [dim for dim in dims if dim not in known_dims]

data_cp = data.transpose(*other_dims, *known_dims)

if projection is None:
projection = data_cp.rio.crs
Expand Down

0 comments on commit ea996ba

Please sign in to comment.