@@ -80,62 +80,3 @@ def load_local_collection(*args, **kwargs):
80
80
spec = openeo_processes_dask .specs .load_collection ,
81
81
implementation = load_local_collection ,
82
82
)
83
-
84
- def resample_cube_spatial_rioxarray (data : RasterCube , target : RasterCube , method : str = "near" ) -> RasterCube :
85
- _log .info ("Running process resample_cube_spatial" )
86
- methods_dict = {
87
- "near" : rasterio .enums .Resampling .nearest ,
88
- "bilinear" : rasterio .enums .Resampling .bilinear ,
89
- "cubic" : rasterio .enums .Resampling .cubic ,
90
- "cubicspline" : rasterio .enums .Resampling .cubic_spline ,
91
- "lanczos" : rasterio .enums .Resampling .lanczos ,
92
- "average" : rasterio .enums .Resampling .average ,
93
- "mode" : rasterio .enums .Resampling .mode ,
94
- "gauss" : rasterio .enums .Resampling .gauss ,
95
- "max" : rasterio .enums .Resampling .max ,
96
- "min" : rasterio .enums .Resampling .min ,
97
- "med" : rasterio .enums .Resampling .med ,
98
- "q1" : rasterio .enums .Resampling .q1 ,
99
- "q3" : rasterio .enums .Resampling .q3 ,
100
- "sum" : rasterio .enums .Resampling .sum ,
101
- "rms" : rasterio .enums .Resampling .rms
102
- }
103
-
104
- if method not in methods_dict :
105
- raise ValueError (
106
- f'Selected resampling method "{ method } " is not available! Please select one of '
107
- f"[{ ', ' .join (methods_dict .keys ())} ]"
108
- )
109
- if len (data .openeo .temporal_dims ) > 0 :
110
- for i ,t in enumerate (data [data .openeo .temporal_dims [0 ]]):
111
- if i == 0 :
112
- resampled_data = data .loc [{data .openeo .temporal_dims [0 ]:t }].rio .reproject_match (
113
- target , resampling = methods_dict [method ]
114
- )
115
- resampled_data = resampled_data .assign_coords ({data .openeo .temporal_dims [0 ]:t }).expand_dims (data .openeo .temporal_dims [0 ])
116
- else :
117
- tmp = data .loc [{data .openeo .temporal_dims [0 ]:t }].rio .reproject_match (
118
- target , resampling = methods_dict [method ]
119
- )
120
- tmp = tmp .assign_coords ({data .openeo .temporal_dims [0 ]:t }).expand_dims (data .openeo .temporal_dims [0 ])
121
- resampled_data = xr .concat ([resampled_data ,tmp ],dim = data .openeo .temporal_dims [0 ])
122
- else :
123
- resampled_data = data .rio .reproject_match (
124
- target , resampling = methods_dict [method ]
125
- )
126
- resampled_data .rio .write_crs (target .rio .crs , inplace = True )
127
-
128
- # Order axes back to how they were before
129
- resampled_data = resampled_data .transpose (* data .dims )
130
-
131
- # Ensure that attrs except crs are copied over
132
- for k , v in data .attrs .items ():
133
- if k .lower () != "crs" :
134
- resampled_data .attrs [k ] = v
135
- return resampled_data
136
-
137
-
138
- PROCESS_REGISTRY ["resample_cube_spatial" ] = Process (
139
- spec = openeo_processes_dask .specs .resample_cube_spatial ,
140
- implementation = resample_cube_spatial_rioxarray ,
141
- )
0 commit comments