Skip to content

Support openeo.api.process.Parameter as resolution in DataCube.resamp…#898

Open
VincentVerelst wants to merge 1 commit into
masterfrom
897-resolution-parameter-resample-spatial
Open

Support openeo.api.process.Parameter as resolution in DataCube.resamp…#898
VincentVerelst wants to merge 1 commit into
masterfrom
897-resolution-parameter-resample-spatial

Conversation

@VincentVerelst
Copy link
Copy Markdown
Collaborator

Fixes #897

@VincentVerelst VincentVerelst requested a review from soxofaan May 11, 2026 14:40
Comment thread openeo/metadata.py
name=dim.name,
extent=dim.extent,
crs=projection,
step=dim.step,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to set step to None to more clearly signal that it is unknown at this point, instead of leaving it unchanged (which is the opposite of what is probably happening)

Comment thread openeo/metadata.py
self,
resolution: Union[float, Tuple[float, float], List[float]] = 0.0,
resolution: Union[float, Tuple[float, float], List[float], "Parameter"] = 0.0,
projection: Union[int, str, None] = None,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also allow projection to be a parameter here, while we're at it?

Comment thread openeo/metadata.py
) -> CubeMetadata:
resolution = normalize_resample_resolution(resolution)
if isinstance(resolution, Parameter):
normalized_resolution = None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
normalized_resolution = None
normalized_resolution = None, None

which will allow to simplify the logic below to practically the original code, I guess

Comment thread tests/test_metadata.py
param = Parameter.number("res", description="The spatial resolution.")
metadata = cube_metadata.resample_spatial(resolution=param)
assert isinstance(metadata, CubeMetadata)
# step must not change because the resolution is unknown at build time
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think step must be made explicitly unknown: e.g. None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow openeo.api.process.Parameter object as resolution in DataCube.resample_spatial()

2 participants