GEE Training——Guideline篇(1)

掩膜的区别:updateMask() 是保留括号内的区域(要注意是在现有图像掩码不为零的区域进行处理)。GEE(10):使用mask、unmask掩膜掉特定值的区域_gee mask_BetterQ.的博客-CSDN博客


GEE学习笔记 五十九:GEE中mosiac、qualityMosiac、max区别_地理遥感生态网的博客-CSDN博客


Image Overview中

影像波段计算:image1和2都是个常数image,cat是把波段合成。

区分multiband和multiband1:前者是把3个image合并到一张image里(变为3个波段),后者select了image3的两个波段。

// Create a constant image.
var image1 = ee.Image(1);
print(image1);

// Concatenate two images into one multi-band image.
var image2 = ee.Image(2);
var image3 = ee.Image.cat([image1, image2]);
print(image3);

// Create a multi-band image from a list of constants.
var multiband = ee.Image([1, 2, 3]);
var multiband1 = image3.select([0, 1]);

select除了用于选择波段,还能给波段改名,如:

var renamed = multiband.select(
    ['constant', 'constant_1', 'constant_2'], // old names
    ['band1', 'band2', 'band3']               // new names
);

RGB合成

波段计算:NDVI的两种计算方式,结果相同

 已有的运算函数:

阈值分割判定裸地:当NDVI<0.2 且 NDWI小于0时

// Create a binary layer using logical operations.
var bare = ndvi.lt(0.2).and(ndwi.lt(0));

夜间灯光数据根据阈值分级:这里也有另一种表达方式,都是if then else的逻辑关系,即如果这个波段灯光大于62,则是3;……

// Load a 2012 nightlights image.
var nl2012 = ee.Image('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS/F182012');
var lights = nl2012.select('stable_lights');

// Define arbitrary thresholds on the 6-bit stable lights band.
var zones = lights.gt(30).add(lights.gt(55)).add(lights.gt(62));

// Display the thresholded image as three distinct zones near Paris.
var palette = ['000000', '0000FF', '00FF00', 'FF0000'];
Map.setCenter(2.373, 48.8683, 8);
Map.addLayer(zones, {min: 0, max: 3, palette: palette}, 'development zones');

用where可以替换影像的一部分像元值:image中云量>5的部分,被替换为replacement中的值。要注意如果要替换的部分直接写数字10,相当于定义了 var replacement = ee.Image(10),其默认的分辨率是1°。

// Load a cloudy Sentinel-2 image.
var image = ee.Image(
  'COPERNICUS/S2_SR/20210114T185729_20210114T185730_T10SEG');
Map.addLayer(image,
             {bands: ['B4', 'B3', 'B2'], min: 0, max: 2000},
             'original image');

// Load another image to replace the cloudy pixels.
var replacement = ee.Image(
  'COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');

// Set cloudy pixels (greater than 5% probability) to the other image.
var replaced = image.where(image.select('MSK_CLDPRB').gt(5), replacement);

// Display the result.
Map.setCenter(-122.3769, 37.7349, 11);
Map.addLayer(replaced,
             {bands: ['B4', 'B3', 'B2'], min: 0, max: 2000},
             'clouds replaced');

下面这个代码,用where替换img3中99的部分为98,分辨率不变。但如果addBands,add的这个波段默认分辨率是1°,但其他波段分辨率不变。

// Load and display an image.
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318');
print(image);

//NDWI
var ndwi = image.normalizedDifference(['B3', 'B5']);
var ndwiViz = {min: 0.5, max: 1, palette: ['00FFFFF','0000FF']};
print(image.select("B1").projection().nominalScale())

var img2 = image.addBands(ee.Image(99))
print(img2.select("constant").projection().nominalScale())
print(img2.select("B1").projection().nominalScale())

var img3 = image.addBands(ndwi)
var img4 = img3.where(ee.Image(99), ee.Image(98))
print(img4.select("nd").projection().nominalScale())

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值