scale#

scale(array: Union[numpy.ndarray, numpy.ma.core.MaskedArray], perc: int = 2) Union[numpy.ndarray, numpy.ma.core.MaskedArray][source]#

Scale a raster given as a np.ndarray between 0 and 1.

The min max are computed with percentiles (2 by default), but can be true min/max if perc=0.

Warning

If 3D, the raster should be in rasterio’s convention: (count, height, width)

Parameters
  • array (Union[np.ndarray, numpy.ma.masked_array]) – Matrix to be scaled

  • perc (int) – Percentile to cut. 0 = min/max, 2 by default

Returns

Scaled matrix

Return type

numpy array