ee.Number.unitScale

Scales the input so that the range of input values [min, max] becomes [0, 1]. Values outside the range are NOT clamped. If min == max, 0 is returned.

UsageReturns
Number.unitScale(min, max)Number
ArgumentTypeDetails
this: numberNumber
minFloat
maxFloat

Examples

Code Editor (JavaScript)

print('-10 scaled between [0, 100]', ee.Number(-10).unitScale(0, 100));  // -0.1
print('10 scaled between [0, 100]', ee.Number(10).unitScale(0, 100));  // 0.1

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

import ee
import geemap.core as geemap

Colab (Python)

print('-10 scaled between [0, 100]:',
      ee.Number(-10).unitScale(0, 100).getInfo())  # -0.1
print('10 scaled between [0, 100]:',
      ee.Number(10).unitScale(0, 100).getInfo())  # 0.1