18
18
from beartype .typing import List , Optional , Tuple , Union
19
19
from typing_extensions import Annotated
20
20
21
+ from eis_toolkit .utilities .nodata import nan_to_nodata , nodata_to_nan
22
+
21
23
app = typer .Typer ()
22
24
23
25
@@ -3135,6 +3137,7 @@ def weights_of_evidence_calculate_weights_cli(
3135
3137
out_rasters_dict = {}
3136
3138
file_name = input_raster .name .split ("." )[0 ]
3137
3139
for key , array in arrays .items ():
3140
+ array = nan_to_nodata (array , raster_meta ["nodata" ])
3138
3141
output_raster_name = file_name + "_weights_" + weights_type + "_" + key
3139
3142
output_raster_path = output_dir .joinpath (output_raster_name + ".tif" )
3140
3143
with rasterio .open (output_raster_path , "w" , ** raster_meta ) as dst :
@@ -3183,13 +3186,15 @@ def weights_of_evidence_calculate_responses_cli(
3183
3186
if raster_weights is not None :
3184
3187
with rasterio .open (raster_weights ) as src :
3185
3188
array_W = src .read (1 )
3189
+ array_W = nodata_to_nan (array_W , src .nodata )
3186
3190
3187
3191
if raster_profile is None :
3188
3192
raster_profile = src .profile
3189
3193
3190
3194
if raster_std is not None :
3191
3195
with rasterio .open (raster_std ) as src :
3192
3196
array_S_W = src .read (1 )
3197
+ array_S_W = nodata_to_nan (array_S_W , src .nodata )
3193
3198
3194
3199
dict_array .append ({"W+" : array_W , "S_W+" : array_S_W })
3195
3200
@@ -3200,12 +3205,15 @@ def weights_of_evidence_calculate_responses_cli(
3200
3205
)
3201
3206
typer .echo ("Progress: 75%" )
3202
3207
3208
+ posterior_probabilities = nan_to_nodata (posterior_probabilities , raster_profile ["nodata" ])
3203
3209
with rasterio .open (output_probabilities , "w" , ** raster_profile ) as dst :
3204
3210
dst .write (posterior_probabilities , 1 )
3205
3211
3212
+ posterior_probabilies_std = nan_to_nodata (posterior_probabilies_std , raster_profile ["nodata" ])
3206
3213
with rasterio .open (output_probabilities_std , "w" , ** raster_profile ) as dst :
3207
3214
dst .write (posterior_probabilies_std , 1 )
3208
3215
3216
+ confidence_array = nan_to_nodata (confidence_array , raster_profile ["nodata" ])
3209
3217
with rasterio .open (output_confidence_array , "w" , ** raster_profile ) as dst :
3210
3218
dst .write (confidence_array , 1 )
3211
3219
@@ -3230,9 +3238,11 @@ def agterberg_cheng_CI_test_cli(
3230
3238
3231
3239
with rasterio .open (input_posterior_probabilities ) as src :
3232
3240
posterior_probabilities = src .read (1 )
3241
+ posterior_probabilities = nodata_to_nan (posterior_probabilities , src .nodata )
3233
3242
3234
3243
with rasterio .open (input_posterior_probabilities_std ) as src :
3235
3244
posterior_probabilities_std = src .read (1 )
3245
+ posterior_probabilities_std = nodata_to_nan (posterior_probabilities_std , src .nodata )
3236
3246
3237
3247
typer .echo ("Progress: 25%" )
3238
3248
0 commit comments