From 2622c8a0dfde52ed42615cd0e9d033ba03fcc38f Mon Sep 17 00:00:00 2001 From: clausmichele Date: Wed, 4 Oct 2023 16:02:06 +0200 Subject: [PATCH] remove unused `resample_cube_spatial_rioxarray` from local processing --- openeo/local/processing.py | 59 -------------------------------------- 1 file changed, 59 deletions(-) diff --git a/openeo/local/processing.py b/openeo/local/processing.py index bd571d354..4adce909d 100644 --- a/openeo/local/processing.py +++ b/openeo/local/processing.py @@ -80,62 +80,3 @@ def load_local_collection(*args, **kwargs): spec=openeo_processes_dask.specs.load_collection, implementation=load_local_collection, ) - -def resample_cube_spatial_rioxarray(data: RasterCube, target: RasterCube, method: str = "near") -> RasterCube: - _log.info("Running process resample_cube_spatial") - methods_dict = { - "near": rasterio.enums.Resampling.nearest, - "bilinear": rasterio.enums.Resampling.bilinear, - "cubic": rasterio.enums.Resampling.cubic, - "cubicspline": rasterio.enums.Resampling.cubic_spline, - "lanczos": rasterio.enums.Resampling.lanczos, - "average": rasterio.enums.Resampling.average, - "mode": rasterio.enums.Resampling.mode, - "gauss": rasterio.enums.Resampling.gauss, - "max": rasterio.enums.Resampling.max, - "min": rasterio.enums.Resampling.min, - "med": rasterio.enums.Resampling.med, - "q1": rasterio.enums.Resampling.q1, - "q3": rasterio.enums.Resampling.q3, - "sum": rasterio.enums.Resampling.sum, - "rms": rasterio.enums.Resampling.rms - } - - if method not in methods_dict: - raise ValueError( - f'Selected resampling method "{method}" is not available! Please select one of ' - f"[{', '.join(methods_dict.keys())}]" - ) - if len(data.openeo.temporal_dims) > 0: - for i,t in enumerate(data[data.openeo.temporal_dims[0]]): - if i == 0: - resampled_data = data.loc[{data.openeo.temporal_dims[0]:t}].rio.reproject_match( - target, resampling=methods_dict[method] - ) - resampled_data = resampled_data.assign_coords({data.openeo.temporal_dims[0]:t}).expand_dims(data.openeo.temporal_dims[0]) - else: - tmp = data.loc[{data.openeo.temporal_dims[0]:t}].rio.reproject_match( - target, resampling=methods_dict[method] - ) - tmp = tmp.assign_coords({data.openeo.temporal_dims[0]:t}).expand_dims(data.openeo.temporal_dims[0]) - resampled_data = xr.concat([resampled_data,tmp],dim=data.openeo.temporal_dims[0]) - else: - resampled_data = data.rio.reproject_match( - target, resampling=methods_dict[method] - ) - resampled_data.rio.write_crs(target.rio.crs, inplace=True) - - # Order axes back to how they were before - resampled_data = resampled_data.transpose(*data.dims) - - # Ensure that attrs except crs are copied over - for k, v in data.attrs.items(): - if k.lower() != "crs": - resampled_data.attrs[k] = v - return resampled_data - - -PROCESS_REGISTRY["resample_cube_spatial"] = Process( - spec=openeo_processes_dask.specs.resample_cube_spatial, - implementation=resample_cube_spatial_rioxarray, -)