Skip to content

Commit

Permalink
remove unused resample_cube_spatial_rioxarray from local processing
Browse files Browse the repository at this point in the history
  • Loading branch information
clausmichele authored and soxofaan committed Oct 16, 2023
1 parent 7ebaff2 commit 2622c8a
Showing 1 changed file with 0 additions and 59 deletions.
59 changes: 0 additions & 59 deletions openeo/local/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

0 comments on commit 2622c8a

Please sign in to comment.