Cloud masking on GEE using Landsat 8 involves the identification and removal of cloud-contaminated pixels from satellite imagery. Landsat 8, equipped with the Operational Land Imager (OLI), captures high-resolution multispectral data. However, cloud cover can hinder the interpretation of Earth’s surface features. Employing cloud masking techniques on GEE enhances the usability of Landsat 8 imagery for various applications, including land cover classification, vegetation monitoring, and change detection.
What is Cloud Masking?
Landsat 8 images are widely used for a variety of applications. However, cloud and cloud shadow cover issues are still a challenge. Clouds and cloud shadows decrease the accuracy of remote sensing application results because they obscure the land surface and the brightening effect of clouds and the darkening effect of cloud shadows influence the reflectance capability of the target object. The cloud masking process solves the problem of a cloud shadow. It is the process of identifying clouds from satellite images and eliminating them to obtain a cloud-free image. Cloud masking ensures that the pixels in the image are transparent and excluded from further analysis.
Cloud Masking Techniques
Several cloud masking techniques can be applied using Landsat 8 data on GEE. One common approach is leveraging the Quality Assessment (QA) band provided with Landsat 8 imagery. The QA band contains information about cloud and shadow cover, allowing for the identification and subsequent masking of these areas. Additionally, users can explore more sophisticated methods, such as the Fmask algorithm, which employs spectral and spatial characteristics to detect clouds and shadows with higher accuracy.
This article focuses on outlining the process of cloud masking step by step using the Landsat 8 surface reflectance dataset in Google Earth Engine.
Select an Area of Interest
You can choose an area of interest by importing a shapefile of the region you are interested in. To achieve this, proceed as follows:
- On the left side panel, click on Assets
- A list of your previously ingested tables (shapefiles) will appear
- Navigate to your shapefile of interest and click on the arrow to import the shapefile into the script.
Cloud Masking Function
Write a function to mask the clouds from the pixel_qa band of Landsat 8 SR data.
function maskL8sr(image) { // Bits 3 and 5 are cloud shadow and cloud, respectively. var cloudShadowBitMask = 1 << 3; var cloudsBitMask = 1 << 5; // Get the pixel QA band. var qa = image.select('pixel_qa'); // Both flags should be set to zero, indicating clear conditions. var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0) .and(qa.bitwiseAnd(cloudsBitMask).eq(0)); // Return the masked image, scaled to reflectance, without the QA bands. return image.updateMask(mask).divide(10000) .select("B[0-9]*") .copyProperties(image, ["system:time_start"]); }
Apply the Function to Image Collection
Map the function over one year of Landsat 8 SR data and apply a median reducer.
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR') .filterDate('2016-01-01', '2016-12-31') .map(maskL8sr) var composite = collection.median()
Display the Final Results
Display the image before and after cloud masking and make a comparison between the two images.
Map.centerObject(table, 12) Map.addLayer(collection, {bands: ['B4', 'B3', 'B2'], min: 0, max: 0.3}, 'original image'); Map.addLayer(composite, {bands: ['B4', 'B3', 'B2'], min: 0, max: 0.3}, 'cloud-masked image');
Original image
Cloud-masked Image
Cloud masking on GEE using Landsat 8