Removing cloudy pixels from rasters

Anurag Sharma
3 min readAug 13, 2024

When working with satellite imagery, I often encounter challenges due to heavy cloud cover, which can obscure the area of interest. Since my work involves analyzing farmlands, it’s crucial to have images with minimal cloud cover. To obtain satellite imagery, I rely on providers like Planet Labs and Sentinel Hub, which offer multi-spectral data. This means that, in addition to the standard RGB bands, the imagery includes spectral bands that are invisible to the naked eye. For example, Planet Labs provides access to several bands, including Coastal Blue, Blue, Green 1, Green, Yellow, Red, Red Edge, and Near-Infrared (NIR).

Below is an example of imagery that was downloaded recently for a farm area -

Each pixel is a 10m x 10m area

Some pixels in the satellite imagery are obscured by clouds, making them unsuitable for further analysis. During the data-cleaning process, we typically remove these unusable pixels. Planet Labs facilitates this by providing, along with the raw image, a UDM (Usable Data Mask) TIFF file. This file includes bands that indicate the condition of each pixel, identifying whether it is clear, cloudy, hazy, and so on.

Here is the band information for a single pixel in the UDM file —

QGIS render of the downloaded tiff file

According to the UDM file, the selected pixel is marked as clear with a 64% confidence level. However, a visual inspection suggests that this pixel may be cloud-covered. In such cases, relying solely on the UDM file for data cleaning may not be effective.

One of the ways we can remove such pixels is by using vegetation indices.

NDVI (Wikipedia) —

The normalized difference vegetation index is a widely-used metric for quantifying the health and density of vegetation using sensor data. It is calculated from spectrometric data at two specific bands: red and near-infrared. The spectrometric data is usually sourced from remote sensors, such as satellites.

NDVI = (nir - red_band) / (nir + red_band)

Reflectance Ratio (R) — A simple ratio of near-infrared band and green visible band

R = (green_band/nir_band)

The following conditions are then applied for each pixel -

  • NDVI > 0.4~0.5
  • R > 2.5

[source]

Results —

The lime green region will be retained after masking

Using the conditions outlined above, we successfully selected regions while excluding some of the cloudy areas. These conditions allow us to create a mask that can be applied to the originally downloaded raw imagery, effectively cropping out unwanted pixels.

However, the effectiveness of this approach may vary depending on the specific region. The threshold values might need adjustment based on the area of interest and its location before applying any masking.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Anurag Sharma
Anurag Sharma

Written by Anurag Sharma

tech, science and programming.

No responses yet

Write a response