导读:
1. 创建和探索如何读取一个假彩色无云的Landsat合成影像;
2.计算归一化燃烧指数;
3.定位变化的区域;
4.生成变更图并使用阈值对变更进行分类。
一、准备影像
1.1 select 用法
1.2 多时相配准、辐射大气校正
这里用的LANDSAT/LC08/C02/T1_L2数据集。
二、创建假彩色合成影像
var visParam = { 'bands': ['swir2', 'nir', 'red'], 'min': 7750, 'max': 22200 }; Map.addLayer(preImage, visParam, 'pre'); Map.addLayer(postImage, visParam, 'post');
Q: 调色板中的'min' 和'max'参数的值是怎么确定的?
三、代码
//----------------------------Section 1 ------------------------------------ var landsat8 = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2') .select( ['SR_B2', 'SR_B3', 'SR_B4', 'SR_B5', 'SR_B6', 'SR_B7'], ['blue', 'green', 'red', 'nir', 'swir1', 'swir2'] ); var point = ee.Geometry.Point([-123.64, 42.96]); Map.centerObject(point, 11); var preImage = landsat8.filterBounds(point) .filterDate('2013-06-01', '2013-06-30') .sort('CLOUD_COVER', true) .first(); print('preImage',preImage); var postImage = landsat8.filterBounds(point) .filterDate('2020-06-01', '2020-06-30') .sort('CLOUD_COVER', true) .first(); print('postImage', postImage); //----------------------------Section 2 ------------------------------------ var visParam = { 'bands': ['swir2', 'nir', 'red'], 'min': 7750, 'max': 22200 }; Map.addLayer(preImage, visParam, 'pre'); Map.addLayer(postImage, visParam, 'post'); //----------------------------Section 3 计算NBR------------------------------------ // Calculate NBR. var nbrPre = preImage.normalizedDifference(['nir', 'swir2']) .rename('nbr_pre'); var nbrPost = postImage.normalizedDifference(['nir', 'swir2']) .rename('nbr_post'); //----------------------------Section 4 Single Date Transformation------------------------------------ // 2-date change. var diff = nbrPost.subtract(nbrPre).rename('change'); var palette = [ '011959', '0E365E', '1D5561', '3E6C55', '687B3E', '9B882E', 'D59448', 'F9A380', 'FDB7BD', 'FACCFA' ]; var visParams = { palette: palette, min: -0.2, max: 0.2 }; Map.addLayer(diff, visParams, 'change'); //----------------------------Section 5 lassify change -------------------------------------- var thresholdGain = 0.10; var thresholdLoss = -0.10; var diffClassified = ee.Image(0); diffClassified = diffClassified.where(diff.lte(thresholdLoss), 2); diffClassified = diffClassified.where(diff.gte(thresholdGain), 1); print('diffClassified', diffClassified); var changeVis = { palette: 'fcffc8,2659eb,fa1373', min: 0, max: 2 }; Map.addLayer(diffClassified.selfMask(), changeVis, 'change classified by threshold');
标签:变化检测,diffClassified,Map,SR,Detection,preImage,var,addLayer,Change From: https://www.cnblogs.com/bltstop/p/18082392