对应的课程为
https://www.bilibili.com/video/BV1Sb411p7TQ?p=4
GEE的数据类型可以分为参数型数据和空间型数据,还有卫星和矩阵数据
其中,参数型数据有:String、Number、Array、List、Dictionary;空间型数据有:Geometry、Feature、Feature Collection、Image、Image Collection
操作 | ||
---|---|---|
显示 | print(string) | |
创建 | ee.String() | |
修改 | string.cat()(拼接) | string.replace()(替换) |
段落 | string.split()(分割) | string.match(匹配) |
查询 | string.slice() | string.length |
1.显示一个String
print("this is a string")
var string = ee.String('this is a string')
print(string)
3.合并两个String
var string1 = ee.String('this is a string1')
var string2 = ee.String('this is a string2')
var cat_str = string1.cat(string2)
print(cat_str)
4.替换
var string1 = ee.String('ABC ADE AFG AHI')
var string2 = string1.replace('A','-')
print(string1,string2)
var string1 = ee.String('ABC ADE AFG AHI')
var string2 = string1.replace('A','-','g')
print(string1,string2)
通过在replace中添加参数’g‘,可以做到全部替换
5.切割
var string1 = ee.String('A_B_C_D')
var string2 = string1.split("_")
print(string1,string2)
6.匹配
var string1 = ee.String('A B C D C')
var string2 = string1.match('c','i')
print(string1,string2)
var string1 = ee.String('1234 5678 90AB')
var string2 = string1.slice(5, 10)
print(string1,string2)
var string1 = ee.String('1234 5678 90AB')
var string2 = string1.slice(5)
print(string1,string2)
长度
var string1 = ee.String('1234 5678 90AB')
var num = string1.length()
print(string1,num)
功能 | 操作 |
---|---|
创建 | ee.Number() |
修改 | number.uint8(); number.Uint8(); number.int8(); number.toInt8() |
比较 | number.eq(); number.neq(); number.and(); number.or(); ee.Algorithms.IsEqua() |
运算 | number.abs(); number.round(); number.pow() |
字位 | number.bitwiseAnd(); number.bitwiseOr(); number.bitwise_and(); number.bitwise_or(); number.leftShift(); number.right_shift() |
1.创建
var number = ee.Number(123456789)
print(number)
var num1 = ee.Number(-3.14159)
var num2 = num1.int8()
var num3 = num1.toInt8()
print(num1, num2, num3)
2.比较
number.eq | number.neq | number.gt | number.gte | number.lt | number.lte |
---|---|---|---|---|---|
= | ≠ | > | ≥ | < | ≤ |
var num1 = ee.Number(10)
var num2 = ee.Number(-10)
var bool = num1.eq(num2)
print(num1, num2, bool)
number.round | number.ceil | number.floor | number.sqrt | number.exp | number.log | number.log10 |
---|---|---|---|---|---|---|
四舍五入 | 向上取整 | 向下取整 | 开方 | 幂 | 对数 | 10底对数 |
var num1 = ee.Number(-3.1415)
var num2 = num1.floor().abs()
print(num1, num2)
var num1 = ee.Number(3.14)
var num2 = ee.Number(3.14)
var num3 = ee.Number(3.141)
var bool1 = ee.Algorithms.IsEqual(num1, num2)
var bool2 = ee.Algorithms.IsEqual(num2, num3)
print(num1, num2, num3)
print(bool1, bool2)
5.位运算
var num1 = ee.Number(1)
var num2 = ee.Number(2)
var num_And = num1.bitwiseAnd(num2)
var num_Or = num1.bitwiseOr(num2)
print('000000001(=1)and 00000010(=2)', num_And)
print('000000001(=1)or 00000010(=2)', num_Or)
bitwiseAnd/Or/Xor/Not = bitwise_and/_or/_xor/_not (与/或/异或/非)
6.位运算(左移或右移)
var num = ee.Number(3)
var num_left = num.leftShift(2)
var num_right = num.rightShift(1)
print("00000011 to 00001100",num_left)
print("00000011 to 00000001",num_right)
number.leftShift = number.left_shift
用途:在Landsat卫星图像中,前8?前12位是用二进制存储的,可以使用位运算对每个像素的云量进行筛选