Skip to main content
Solved

PlanetScope cloud filtering

  • 24 June 2024
  • 1 reply
  • 84 views

Hi there,

I recently created a collection of PlanetScope imagery using the Planet Subscriptions API and applied a 50% cloud filter. I’m now using that collection in the Statistical API and would like to only consider imagery with 20% cloud cover (i.e., 80% clear pixels). Let me know if you have any tips for filtering these data.

Thank you!

1 reply

Userlevel 3
Badge +5

Hey @m-lindman, to calculate the cloud cover percentage, you can use the Statistical API.  In your evalscript, you can return use the Useable Data Mask (UDM) clear band to return a 1 for clear and a 0 for not clear. When used with the Statistical API, this value will be averaged over the input area of interest, returning effectively the percentage of pixels that are clear.  For example, if 80% of pixels are clear (UDM clear band with a value of 1), then the mean clear value returned by the Statistical API would be 0.8.

Below is a sample evalscript that you could use to get the mean clear value:

//VERSION=3
//Calculate mean UDM clear value

function setup() {
return {
input: [{
bands: [
"dataMask",
"green",
"red",
"clear",
"blue"
]
}],
output: [
{ id: "true_color", bands: 4, sampleType: "FLOAT32" },
{ id: "clear", bands: 1, sampleType: "FLOAT32" },
{ id: "dataMask", bands: 1 },
]
}
}

function evaluatePixel(sample) {

return {
true_color: [sample.red, sample.green, sample.blue, sample.dataMask],
clear: [sample.clear],
dataMask: [sample.dataMask],
};
}

The resulting mean cloud can be used to filter out scenes below your desired threshold:

Distribution of clear % across dates

If you are using EO Browser, you can test out what this looks like using the Statistic tool and this PlanetScope evalscript (note: switch to EO Browser tab and copy/paste).  When you use this evalscript and generate statistics for an AOI, you will be able to filter the chart with the cloud filter:

Cloud percentage set to 100%
Cloud percentage set to 0%

 

Reply