File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,6 @@ def get_color_table(raster_dataset: rasterio.io.DatasetReader, band: int):
185
185
return None
186
186
187
187
188
-
189
188
def rasterio_metadata (
190
189
file_path : str ,
191
190
bands_info : List [Tuple [int , str ]],
@@ -424,7 +423,12 @@ def not_enough_samples():
424
423
)
425
424
if not raster_is_masked :
426
425
for band in bands :
427
- not_masked_samples [band ].append (sample [band - 1 ])
426
+ band_sample = sample [band - 1 ]
427
+ is_valid_sample = not (
428
+ np .isinf (band_sample ) or np .isnan (band_sample )
429
+ )
430
+ if is_valid_sample :
431
+ not_masked_samples [band ].append (band_sample )
428
432
429
433
iterations += 1
430
434
@@ -507,8 +511,14 @@ def raster_band_approx_stats(
507
511
_sum = 0
508
512
sum_squares = 0
509
513
if count > 0 :
510
- _sum = int (np .sum (samples_band ))
511
- sum_squares = int (np .sum (np .array (samples_band ) ** 2 ))
514
+ try :
515
+ _sum = int (np .sum (samples_band ))
516
+ except (OverflowError , ValueError ):
517
+ _sum = 0
518
+ try :
519
+ sum_squares = int (np .sum (np .array (samples_band ) ** 2 ))
520
+ except (OverflowError , ValueError ):
521
+ sum_squares = 0
512
522
513
523
if basic_stats :
514
524
quantiles = None
You can’t perform that action at this time.
0 commit comments