错误
Error generating chart: Image.select: Band pattern 'dmultiindex' did not match any bands. Available bands: [NDVI_before, NBR_before, gNDVI_before, MIRBI_before]
Error generating chart: Dictionary.get: Dictionary does not contain key: 'dmultiindex_histogram'.
threshold
Number (Error)
Dictionary.get: Dictionary does not contain key: 'dmultiindex_histogram'.
Histogram, Mean, and Variance:
Dictionary (Error)
Image.select: Band pattern 'multiindex_after' did not match any bands. Available bands: [NDVI_after, NBR_after, gNDVI_after, MIRBI_after]
代码
var image = ee.Image("users/elahezafariansku/ESRI_Rangeland_2021"),
table = ee.FeatureCollection("users/elahezafariansku/helen");
// Select rangeland class from ESRI 2021
var remapped = image.select(['remapped']);
var rangeland = remapped.addBands(ee.Image(1).updateMask(remapped.gt(1)).rename('range'));
print('Rangeland:', rangeland);
//clip rangeland with boundry
var helen= rangeland.select(1).clip(table).reduceToVectors({
geometry: table,
scale: 10,
})
var before = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20210611T071621_20210611T072134_T39SVR')
.clip(helen);
var after = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20210626T071619_20210626T072134_T39SVR')
.clip(helen);
// Optional viewing of cropped images
Map.centerObject(helen, 12);
Map.addLayer(before, {bands: ['B4', 'B3', 'B2'], min: 0, max: 3000}, 'Before fire');
Map.addLayer(after, {bands: ['B4', 'B3', 'B2'], min: 0, max: 3000}, 'After Fire');
// Calculate indices for the before image
var gNDVIbefore= before.normalizedDifference(['B8', 'B3']).rename('gNDVI_before');
print(gNDVIbefore, 'gNDVIbefore')
var NDVIbefore = before.normalizedDifference(['B8', 'B4']).rename('NDVI_before');
print(NDVIbefore, 'NDVIbefore')
var NBRbefore = before.normalizedDifference(['B8', 'B12']).rename('NBR_before');
print(NBRbefore, 'NBRbefore')
var MIRBIbefore = before.expression(
'10 * B12 - 9.8 * B11 + 2',
{
'B12': before.select('B12'),
'B11': before.select('B11')
}
).rename('MIRBI_before');
print(MIRBIbefore, 'MIRBIbefore')
// Calculate indices for the after image
var gNDVIafter= after.normalizedDifference(['B8', 'B3']).rename('gNDVI_after');
print(gNDVIafter,'gNDVIafter')
var NDVIafter = after.normalizedDifference(['B8', 'B4']).rename('NDVI_after');
var NBRafter = after.normalizedDifference(['B8', 'B12']).rename('NBR_after');
var MIRBIafter = after.expression(
'10 * B12 - 9.8 * B11 + 2',
{
'B12': after.select('B12'),
'B11': after.select('B11')
}
).rename('MIRBI_after');
// Calculate differences in indices
var dgNDVI = gNDVIbefore.subtract(gNDVIafter);
var dNDVI = NDVIbefore.subtract(NDVIafter);
var dNBR = NBRbefore.subtract(NBRafter);
var dMIRBI = MIRBIbefore.subtract(MIRBIafter);
// Calculate dataset before the event
var multiindex_before = NDVIbefore.addBands(NBRbefore).addBands(gNDVIbefore).addBands(MIRBIbefore)
print(multiindex_before,
文章评论