Update aggregate_spatial process implementation#268
Update aggregate_spatial process implementation#268jzvolensky wants to merge 12 commits intoOpen-EO:mainfrom
Conversation
Feature/load stac odc
…g_spatial(temporary), added disclaimer to report.md with the most up to date instructions while the docs are being reworked
|
@jzvolensky the tests are failing, please try to fix them. |
|
Hi @clausmichele @ValentinaHutter, So I ran into a bit of trouble trying to rework the We have discussed the possibility of adding a Now before dealing with that I tried to simply implement the first we add the option to add context: def aggregate_spatial(
data: RasterCube,
geometries,
reducer: Union[str, Callable],
chunk_size: int = 2,
context: Optional[Dict[str, str]] = None,
) -> VectorCube:then here is an example of how we can supply the method: aggregate = s2_datacube.aggregate_spatial(geometries=polys, reducer="mean", context={"method": "exactextract"})The problem is that in the real world the REDUCER: functools.partial(<function OpenEOProcessGraph._map_node_to_callable.<locals>.node_callable at 0x7fd3bfdf3250>, parent_callables=[])Which is fine for the ValueError: functools.partial(<function OpenEOProcessGraph._map_node_to_callable.<locals>.node_callable at 0x7fd3bfdf3250>, parent_callables=[]) is not a valid aggregation.I tried to dig in the Otherwise, we are not able to match the user provider reducer statistic with what is support by Let me know if you have any ideas. Ideally what we want to end up with is to have a list of processes which match the ones in |
|
@jzvolensky you can get it in this way: _process = partial(
process_registry["mean"].implementation,
ignore_nodata=True,
data=ParameterReference(from_parameter="data"),
)
print(_process.__repr__())outputs |
This is great, and will probably be useful for the test. however in the implementation code it doesnt do anything differently than what I have been doing. Basically in the implementation we need to deconstruct the print(f"REDUCER: {reducer}")
functools.partial(<function OpenEOProcessGraph._map_node_to_callable.<locals>.node_callable at 0x7fc62e859f30>, parent_callables=[]) print(f"REDUCER REPR: {reducer.__repr__()}")
functools.partial(<function OpenEOProcessGraph._map_node_to_callable.<locals>.node_callable at 0x7fc62e859f30>, parent_callables=[])which is unfortunate :( |
|
@jzvolensky try with import inspect
inspect.getsource(reducer.func)Edit: after several trials I'm also stuck. Probably it's not possible, with the current openeo-pg-parser-networkx code, to reconstruct from a Callable the various functions that are being called in series? @GeraldIr @ValentinaHutter |

aggregate_spatialimprovements EOEPCA/openeo-processes-dask#1We have been investigating the performance of the
aggregate_spatialwith different datasets. Currently it is not doing very well.We have discovered that certain methods such as
iteratedo not scale well at all. Theexactextractmethod seems to be doing much better (see here https://gist.github.com/clausmichele/6d9bba3a82f39c8c91c0cf5d263e1521)The current idea is that we make the
exactextractmethod the default method. Comment from Michele:"However, since it doesn't allow callbacks as a function to be applied to the data within the polygon, the code should select a different method if a callback/function has to be applied to the data."
So this will need to be taken into account.
The following improvement will be made: The geometries get reprojected to the data CRS and the resulting vector datacube has the CRS of the input data.
This is currently work in progress. Feel free to add some comments or suggestions!
Thanks.
cc @clausmichele