Blinder la normalisation terrain contre les tuiles d'altitude constante
This commit is contained in:
@ -261,7 +261,9 @@ def _apply_colormap(data, tif_file, resolution=None):
|
|||||||
if len(valid_data) == 0:
|
if len(valid_data) == 0:
|
||||||
return data, 'terrain', Path(tif_file).stem.replace('_', ' ').title(), '', '', False
|
return data, 'terrain', Path(tif_file).stem.replace('_', ' ').title(), '', '', False
|
||||||
p2, p98 = np.percentile(valid_data, (2, 98))
|
p2, p98 = np.percentile(valid_data, (2, 98))
|
||||||
data = np.clip((data - p2) / (p98 - p2), 0, 1)
|
# Garde contre les tuiles quasi constantes : plage nulle → division par zéro
|
||||||
|
span = max(p98 - p2, 1e-6)
|
||||||
|
data = np.clip((data - p2) / span, 0, 1)
|
||||||
title = Path(tif_file).stem.replace('_', ' ').title()
|
title = Path(tif_file).stem.replace('_', ' ').title()
|
||||||
return data, 'terrain', title, 'Altitude normalisée', '', False
|
return data, 'terrain', title, 'Altitude normalisée', '', False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user