我正在尝试通过澳大利亚的云遮罩和陆地遮罩来计算年度NDVI。
我收到此错误
图像(错误)reduce.mean:映射错误(ID = 0):Image.bitwiseAnd:按位操作数只能是整数。
我的代码是https://code.earthengine.google.com/?scriptPath=users%2Ftafzilamouly%2Ffpc%3AEXPLORE
我已通过将shapefile转换为几何图形解决了该问题。
但是,对于以下代码,我现在遇到“错误创建或提交任务请求有效负载大小超出限制:4194304字节”。
请注意,改变比例尺不是我的选择,我需要30 m比例尺。
var table = ee.FeatureCollection("users/tafzilamouly/QLD"),
L5 = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR"),
hansen = ee.Image("UMD/hansen/global_forest_change_2018_v1_6");
//Filter region and time period
var L52009annual= L5.filterDate('2009-01-01',"2009-12-31")
//var L52009quarter= L5.filterDate('2009-04-01',"2009-06-30")
var AUS= ee.FeatureCollection(table)
var QLD= AUS.geometry()
var Australia2009annual= ee.ImageCollection(L52009annual).filterBounds(QLD)
//var Australia2009quarter= L52009quarter.clipToCollection(AUS)
//Map.addLayer(Australia2009annual, {}, 'Australia2009annual')
//Map.addLayer(Australia2009quarter, {}, 'Australia2009quarter')
//NDVI
var addNDVI= function addNDVI(image){
var ndvi= image.normalizedDifference(['B4', 'B3']).rename('NDVI');
return image.addBands(ndvi);
};
// Cloud mask
var cloudMaskL457 = function(image) {
var qa = image.select('pixel_qa');
// If the cloud bit (5) is set and the cloud confidence (7) is high
// or the cloud shadow bit is set (3), then it's a bad pixel.
var cloud = qa.bitwiseAnd(1 << 5)
.and(qa.bitwiseAnd(1 << 7))
.or(qa.bitwiseAnd(1 << 3))
// Remove edge pixels that don't occur in all bands
var mask2 = image.mask().reduce(ee.Reducer.min());
return image.updateMask(cloud.not()).updateMask(mask2);
};
// land mask
var landMask = function(image) {
var datamask = hansen.select('datamask');
var mask = datamask.eq(1);
return image.updateMask(mask);
};
var NDVI2009annual= ee.ImageCollection(Australia2009annual)
.map(addNDVI)
.map(cloudMaskL457)
.map(landMask)
.mean()
//print(NDVI2009annual)
var NDVI= NDVI2009annual.select('NDVI')
var positiveNDVI2009annual= NDVI.mask(NDVI)
print(positiveNDVI2009annual)
Map.addLayer(positiveNDVI2009annual, {}, 'positiveNDVI2009annual')
Export.image.toDrive({
image: positiveNDVI2009annual,
description: 'NDVI_2009_annual',
region: QLD,
scale: 30,
fileFormat: 'GeoTIFF',
maxPixels: 33491829976,
});