GEE有很多类型的数据
本文主要介绍ee.Number
的常见指令方法内容,完整指令方法见GEE ee.Number
ee.Number
有以下常见指令方法内容
print(number)
ee.Number()
ee.Number.eq()
、ee.Number.neq()
、ee.Number.lt()
、ee.Number.lte()
、ee.Number.gt()
、ee.Number.gte()
ee.Number.unitScale
ee.Number.abs
ee.Number.round
ee.Number.ceil
ee.Number.floor
ee.Number.format
ee.Number.aside
ee.Number.sqrt
ee.Number.cbrt
ee.Number.pow
ee.Number.log
ee.Number.log10
ee.Number.max
ee.Number.min
ee.Number.hypot
ee.Number.first
ee.Number.firstNonZero
ee.Number.and
ee.Number.or
ee.Number.not
ee.Number.add
ee.Number.subtract
ee.Number.multiply
ee.Number.divide
ee.Number.mod
ee.Number.sin
ee.Number.cos
ee.Number.tan
ee.Number.asin
ee.Number.acos
ee.Number.atan
ee.Number.sinh
ee.Number.cosh
ee.Number.tanh
ee.Number.signum
ee.Number.bitwiseAnd
ee.Number.bitwiseNot
ee.Number.bitwiseOr
ee.Number.bitwiseXor
ee.Number.leftShift
ee.Number.rightShift
ee.Number.trigamma
ee.Number.gamma
ee.Number.gammainc
ee.Number.digamma
ee.Number.atan2
ee.Number.clamp
ee.Number.parse
ee.Number.format
ee.Number.int / ee.Number.toInt
ee.Number.long / ee.Number.toLong
ee.Number.short / ee.Number.toShort
ee.Number.byte / ee.Number.toByte
ee.Number.double / ee.Number.toDouble
ee.Number.float / ee.Number.toFloat
ee.Number.sin
用法
Number.sin()
案例
// Input angle in radians. 弧度
print('Sine of 0', ee.Number(0).sin()); // 0
print('Sine of π/2', ee.Number(Math.PI/2).sin()); // 1
print('Sine of 3π/2', ee.Number(3*Math.PI/2).sin()); // -1
// Convert degrees to radians. 角度
var degrees = 45;
var radians = degrees * (Math.PI/180);
print('Sine of 45 degrees', ee.Number(radians).sin()); // 0.707106781
ee.Number.cos
用法
Number.cos()
案例
// Input angle in radians.
print('Cosine of 0', ee.Number(0).cos()); // 1
print('Cosine of π/2', ee.Number(Math.PI/2).cos()); // 0 (nearly)
print('Cosine of π', ee.Number(Math.PI).cos()); // -1
// Convert degrees to radians.
var degrees = 45;
var radians = degrees * (Math.PI/180);
print('Cosine of 45 degrees', ee.Number(radians).cos()); // 0.707106781
ee.Number.tan
用法
Number.tan()
案例
// Input angle in radians.
print('Tangent of 0', ee.Number(0).tan()); // 0
print('Tangent of π/2', ee.Number(Math.PI/2).tan()); // 16331239353195370
print('Tangent of π', ee.Number(Math.PI).tan()); // 0 (nearly)
// Convert degrees to radians.
var degrees = 45;
var radians = degrees * (Math.PI/180);
print('Tangent of 45 degrees', ee.Number(radians).tan()); // 1 (nearly)
ee.Number.asin
用法
Number.asin()
案例
// The domain of arcsine is [-1,1], inputs outside the domain are invalid.
print('Arcsine of -1', ee.Number(-1).asin()); // -1.570796326 (-π/2)
print('Arcsine of 0', ee.Number(0).asin()); // 0
print('Arcsine of 1', ee.Number(1).asin()); // 1.570796326 (π/2)
ee.Number.acos
用法
Number.acos()
案例
// The domain of arccosine is [-1,1], inputs outside the domain are invalid.
print('Arccosine of -1', ee.Number(-1).acos()); // 3.141592653 (π)
print('Arccosine of 0', ee.Number(0).acos()); // 1.570796326 (π/2)
print('Arccosine of 1', ee.Number(1).acos()); // 0
ee.Number.atan
用法
Number.atan()
案例
print('Arctangent of -1e13', ee.Number(-1e13).atan()); // -1.570796326 (-π/2)
print('Arctangent of -1', ee.Number(-1).atan()); // -0.785398163
print('Arctangent of 0', ee.Number(0).atan()); // 0
print('Arctangent of 1', ee.Number(1).atan()); // 0.785398163
print('Arctangent of 1e13', ee.Number(1e13).atan()); // 1.570796326 (π/2)
ee.Number.sinh
用法
Number.sinh()
案例
// Input angle in radians.
print('Hyperbolic sine of -5', ee.Number(-5).sinh()); // -74.203210577
print('Hyperbolic sine of -1', ee.Number(-1).sinh()); // -1.175201193
print('Hyperbolic sine of 0', ee.Number(0).sinh()); // 0
print('Hyperbolic sine of 1', ee.Number(1).sinh()); // 1.175201193
print('Hyperbolic sine of 5', ee.Number(5).sinh()); // 74.203210577
// Convert degrees to radians.
var degrees = 45;
var radians = degrees * (Math.PI/180);
print('Hyperbolic sine of 45 degrees',
ee.Number(radians).sinh()); // 0.868670961
ee.Number.cosh
用法
Number.cosh()
案例
// Input angle in radians.
print('Hyperbolic cosine of -5', ee.Number(-5).cosh()); // 74.209948524
print('Hyperbolic cosine of -1', ee.Number(-1).cosh()); // 1.543080634
print('Hyperbolic cosine of 0', ee.Number(0).cosh()); // 1
print('Hyperbolic cosine of 1', ee.Number(1).cosh()); // 1.543080634
print('Hyperbolic cosine of 5', ee.Number(5).cosh()); // 74.209948524
// Convert degrees to radians.
var degrees = 45;
var radians = degrees * (Math.PI/180);
print('Hyperbolic cosine of 45 degrees',
ee.Number(radians).cosh()); // 1.324609089
ee.Number.tanh
用法
Number.tanh()
案例
// Input angle in radians.
print('Hyperbolic tangent of -5', ee.Number(-5).tanh()); // -0.999909204
print('Hyperbolic tangent of -1', ee.Number(-1).tanh()); // -0.761594155
print('Hyperbolic tangent of 0', ee.Number(0).tanh()); // 0
print('Hyperbolic tangent of 1', ee.Number(1).tanh()); // 0.761594155
print('Hyperbolic tangent of 5', ee.Number(5).tanh()); // 0.999909204
// Convert degrees to radians. 角度转弧度
var degrees = 45;
var radians = degrees * (Math.PI/180);
print('Hyperbolic tangent of 45 degrees',
ee.Number(radians).tanh()); // 0.655794202
ee.Number.signum
计算输入的符号函数(sign);如果输入为零,则为零,如果输入大于零,则为 1,如果输入小于零,则为 -1。
用法
Number.signum()
案例
print('Sign of -5', ee.Number(-5).signum()); // -1
print('Sign of 0', ee.Number(0).signum()); // 0
print('Sign of 5', ee.Number(5).signum()); // 1
先将输入的数值转成二进制形式,然后把相对应位置的两个数值进行运算,包括And Or Xor Not
ee.Number.bitwiseAnd
用法
Number.bitwiseAnd(right)
案例
/**
* Unsigned 8-bit type example.
*
* 25 as binary: 00011001
* 21 as binary: 00010101
* Both digits 1?: 00010001
*
* 00010001 is unsigned 8-bit binary for 17.
*/
print(ee.Number(25).bitwiseAnd(21)); // 17
ee.Number.bitwiseNot
用法
Number.bitwiseNot()
案例
/**
* Unsigned 8-bit type example.
*
* 25 as binary: 00011001
* Flip each digit: 11100110
*
* 11100110 is signed 8-bit binary for -26.
* (binary interpreted using smallest signed integer type containing the input).
*/
print(ee.Number(25).bitwiseNot()); // 26
ee.Number.bitwiseOr
用法
Number.bitwiseOr(right)
案例
/**
* Unsigned 8-bit type example.
*
* 25 as binary: 00011001
* 21 as binary: 00010101
* Either digit 1?: 00011101
*
* 00011101 is unsigned 8-bit binary for 29.
*/
print(ee.Number(25).bitwiseOr(21)); // 29
ee.Number.bitwiseXor
用法
Number.bitwiseXor(right)
案例
/**
* Unsigned 8-bit type example.
*
* 25 as binary: 00011001
* 21 as binary: 00010101
* Only one digit is 1?: 00001100
*
* 00001100 is unsigned 8-bit binary for 12.
*/
print(ee.Number(25).bitwiseXor(21)); // 12
ee.Number.leftShift
用法
Number.leftShift(right)
案例
/**
* Unsigned 8-bit type example.
*
* 20 as binary: 00010100
* Left shift 2: 01010000
*
* 01010000 is binary for 80.
*/
print(ee.Number(20).leftShift(2)); // 80
ee.Number.rightShift
用法
Number.rightShift(right)
案例
/**
* Unsigned 8-bit type example.
*
* 20 as binary: 00010100
* Right shift 2: 00000101
*
* 00000101 is binary for 5.
*/
print(ee.Number(20).rightShift(2)); // 5
ee.Number.trigamma
用法
Number.trigamma()
案例
print('Trigamma for -100', ee.Number(-100).trigamma()); // Infinity
print('Trigamma for 0.001', ee.Number(0.001).trigamma()); // 1000001.642533195
print('Trigamma for 0.5', ee.Number(0.5).trigamma()); // 4.934802200
print('Trigamma for 1', ee.Number(1).trigamma()); // 1.644934066
print('Trigamma for 100', ee.Number(100).trigamma()); // 0.010050166
print('Trigamma for 200', ee.Number(200).trigamma()); // 0.005012520
ee.Number.gamma
用法
Number.gamma()
案例
// Values less than or equal to 0 are invalid.
print('Gamma for 0.001', ee.Number(0.001).gamma()); // 999.423772484
print('Gamma for 0.5', ee.Number(0.5).gamma()); // 1.772453850
print('Gamma for 1', ee.Number(1).gamma()); // 1
print('Gamma for 100', ee.Number(100).gamma()); // 9.332621544e+155
print('Gamma for 200', ee.Number(200).gamma()); // Infinity
ee.Number.gammainc
用法
Number.gammainc(right)
案例
print('Lower incomplete gamma function for x = 0, a = 1',
ee.Number(0).gammainc(1)); // 0
print('Lower incomplete gamma function for x = 1, a = 1',
ee.Number(1).gammainc(1)); // 0.632120558
print('Lower incomplete gamma function for x = 10, a = 1',
ee.Number(10).gammainc(1)); // 0.999954600
print('Lower incomplete gamma function for x = -1, a = 1',
ee.Number(-1).gammainc(1)); // NaN
print('Lower incomplete gamma function for x = 10, a = -1',
ee.Number(10).gammainc(-1)); // NaN
ee.Number.digamma
用法
Number.digamma()
案例
print('Digamma for -1.5', ee.Number(-1.5).digamma()); // 0.703156637
print('Digamma for -1', ee.Number(-1).digamma()); // -Infinity
print('Digamma for 0', ee.Number(0).digamma()); // -Infinity
print('Digamma for 0.5', ee.Number(0.5).digamma()); // -1.963510028
print('Digamma for 1', ee.Number(1).digamma()); // -0.577215667
print('Digamma for 100', ee.Number(100).digamma()); // 4.600161852
print('Digamma for 1e13', ee.Number(1e13).digamma()); // 29.933606208