I need assistance for solving a problem with Landsat 5 surface reflectance image's cloud mask.
I am new to this tool/programming and want to try this tool to process cloud mask. Through the provided open source code in the web page of Goole Earth Engine, the processing code is composed as below.
However, I would like to request help to debug this error message "Error: Invalid argument: 'image' must be of type Image."
var cloudy_scene = ee.Image('LANDSAT/LT5_SR/LT5*************');
Map.centerObject(cloudy_scene);
Map.addLayer(cloudy_scene,{},'all_bands_cloud');
// Load a Landsat 5 image collection.
var collection = ee.ImageCollection("LANDSAT/LT5_SR")
// Filter to get a geometry representing an export region.
.filterBounds(ee.Geometry.Rectangle([***.***,**.***,***.***,**.***]))
// Filter to get the years/months/days of data.
.filterDate('1993-01-01', '1993-03-01') // filter to your favorite period
// Sort the collection in chronological order.
.sort('system:time_start', true);
//Details for cfmask
//0=clear
//1=water
//2=shadow
//3=snow
//4=cloud
var masked = collection.map(function(image){
return image.updateMask(cloudy_scene.select(['cfmask']).neq(4))
});
// Apply the mask to the image and display the result.
Map.addLayer(masked, {}, 'masked');
var geometry = ee.Geometry.Rectangle([***.***,**.***,***.***,**.***]);
//export the image, specifying scale and region.
Export.image.toDrive({
image: masked,
description: 'ImageToDrive',
scale: 30,
region: geometry
});
Best Answer
Ok, interestingly your script ran through without giving me any error. But if you want to mask out clouds and shadows in your specific image (as you said in your comment) you can do it like this:
Edit:
GEE requires the data types of an image to be identical if you want to export it. If you
print
the masked image to the console you'll see that there are additional 8bit bands. I assumed you're interested in the surface reluctance only, so I added a list of bands for export and Iselect
them within the export function.If you want to export all bands, you need to cast them in a common datatype like
uint16
.