目录
错误
Error in map(ID=LC08_044034_20130603): Image.select: Band pattern 'BQA' did not match any bands. Available bands: [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, QA_PIXEL, QA_RADSAT, SAA, SZA, VAA, VZA]
原始代码
var roi = /* color: #d63000 */ee.Geometry.Point([-121.9353461265564, 37.56180984982223]),
l8toa = ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA");
Map.centerObject(roi, 10);
// This field contains UNIX time in milliseconds.
var timeField = 'system:time_start';
// Use this function to mask clouds in Landsat 8 imagery.
var maskClouds = function(image) {
var quality = image.select('BQA');
var cloud01 = quality.eq(61440);
var cloud02 = quality.eq(53248);
var cloud03 = quality.eq(28672);
var mask = cloud01.or(cloud02).or(cloud03).not();
return image.updateMask(mask);
};
// Use this function to add variables for NDVI, time and a constant
// to Landsat 8 imagery.
var addVariables = function(image) {
// Compute time in fractional years since the epoch.
var date = ee.Date(image.get(timeField));
var years = date.difference(ee.Date('1970-01-01'), 'year');
// Return the image with the added bands.
return image
// Add an NDVI band.
.addBands(image.normalizedDifference(['B5', 'B4']).rename('NDVI')).float()
// Add a time band.
.addBands(ee.Image(years).rename('t').float())
// Add a constant band.
.addBands(ee.Image.constant(1));
};
// Remove clouds, add variables and filter to the area of interest.
var filteredLandsat = l8toa
.filterBounds(roi)
.map(maskClouds)
.map(addVariables);
// Plot a time series of NDVI at a single location.
var l8Chart = ui.Chart.image.series(filteredLandsat.select('NDVI'), roi)
.setChartType('ScatterChart')
.setOptions({
title: 'Landsat 8 NDVI time series at ROI',
trendlines: {0: {
color: 'CC0000'
}},
lineWidth: 1,
pointSize: 3,
});
print(l8Chart);
Landsat 8 TOA数据介绍
NameDescriptionResolutionWavelengthB1
Coastal aerosol
30 meters0.43 - 0.45 μmB2
Blue
30 meters0.45 - 0.51 μmB3
Green
30 meters0.53 - 0.59 μmB4
Red
30 meters0.64 - 0.67 μmB5
Near infrared
30 meters0.85 - 0.88 μmB6
Shortwave infrared 1
30 meters1.57 - 1.65 μmB7
Shortwave infrared 2
30 meters2.11 - 2.29 μmB8
Band 8 Panchromatic
15 meters0.52 - 0.90 μmB9
Cirrus
30 meters1.36 - 1.38 μmB10
Thermal infrared 1, resampled from 100m to 30m
30 meters10.60 - 11.19 μmB11
Thermal infrared 2, resampled from 100m to 30m
30 meters11.50 - 12.51 μmQA_PIXEL
Landsat Collection 2 OLI/TIRS QA Bitmask
30 metersQA_PIXEL Bitmask
- Bit 0: Fill
- 0: Image data
- 1: Fill data
- Bit 1: Dilated Cloud
- 0: Cloud is not dilated or no cloud
- 1: Cloud dilation
- Bit 2: Cirrus
- 0: Cirrus Confidence: no confidence level set or Low Confidence
- 1: High confidence cirrus
- Bit 3: Cloud
- 0: Cloud confidence is not high
- 1: High confidence cloud
- Bit 4: Cloud Shadow
- 0: Cloud Shadow Confidence is not high
- 1: High confidence cloud shadow
- Bit 5: Snow
- 0: Snow/Ice Confidence is not high
- 1: High confidence snow cover
- Bit 6: Clear
- 0: Cloud or Dilated Cloud bits are set
- 1: Cloud and Dilated Cloud bits are not set
- Bit 7: Water
- 0: Land or cloud
- 1: Water
- Bits 8-9: Cloud Confidence
- 0: No confidence level set
- 1: Low confidence
- 2: Medium confidence
- 3: High confidence
- Bits 10-11: Cloud Shadow Confidence
- 0: No confidence level set
- 1: Low confidence
- 2: Reserved
- 3: High confidence
- Bits 12-13: Snow / Ice Confidence
- 0: No confidence level set
- 1: Low confidence
- 2: Reserved
- 3: High confidence
- Bits 14-15: Cirrus Confidence
- 0: No confidence level set
- 1: Low confidence
- 2: Reserved
- 3: High confidence
QA_RADSAT
Radiometric saturation QA
30 metersQA_RADSAT Bitmask
- Bit 0: Band 1 data saturated
- Bit 1: Band 2 data saturated
- Bit 2: Band 3 data saturated
- Bit 3: Band 4 data saturated
- Bit 4: Band 5 data saturated
- Bit 5: Band 6 data saturated
- Bit 6: Band 7 data saturated
- Bit 7: Unused
- Bit 8: Band 9 data saturated
- Bits 9-10: Unused
- Bit 11: Terrian occlusion
- 0: No terrain occlusion
- 1: Terrain occlusion
SAA
Solar Azimuth Angle
30 metersSZA
Solar Zenith Angle
30 metersVAA
View Azimuth Angle
30 metersVZA
View Zenith Angle
30 meters
错误解析
这里我们可以看到很明显的提示,这里的波段中是没有BQA这个波段的,所以这里我们需要进行检查,或者是不是错用了landsat C01之前的数据。这里我们应该使用正常的去云的函数。
正确的代码
var roi = /* color: #d63000 */ee.Geometry.Point([-121.9353461265564, 37.56180984982223]),
l8toa = ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA");
Map.centerObject(roi, 10);
// Use this function to mask clouds in Landsat 8 imagery.
var maskClouds = function(image) {
var qa = image.select('QA_PIXEL');
/// Check that the cloud bit is off.
// See https://www.usgs.gov/media/files/landsat-8-9-olitirs-collection-2-level-1-data-format-control-book
var mask = qa.bitwiseAnd(1 << 3).eq(0);
return image.updateMask(mask);
};
// This field contains UNIX time in milliseconds.
var timeField = 'system:time_start';
// Use this function to add variables for NDVI, time and a constant
// to Landsat 8 imagery.
var addVariables = function(image) {
// Compute time in fractional years since the epoch.
var date = ee.Date(image.get(timeField));
var years = date.difference(ee.Date('1970-01-01'), 'year');
// Return the image with the added bands.
return image
// Add an NDVI band.
.addBands(image.normalizedDifference(['B5', 'B4']).rename('NDVI')).float()
// Add a time band.
.addBands(ee.Image(years).rename('t').float())
// Add a constant band.
.addBands(ee.Image.constant(1));
};
// Remove clouds, add variables and filter to the area of interest.
var filteredLandsat = l8toa
.filterBounds(roi)
.map(maskClouds)
.map(addVariables);
// Plot a time series of NDVI at a single location.
var l8Chart = ui.Chart.image.series(filteredLandsat.select('NDVI'), roi)
.setChartType('ScatterChart')
.setOptions({
title: 'Landsat 8 NDVI time series at ROI',
trendlines: {0: {
color: 'CC0000'
}},
lineWidth: 1,
pointSize: 3,
});
print(l8Chart);