Reputation: 11
I'm running an image collection through an NDWI
function. I'm trying to filter out images with a lot of clouds. Sentinel-2 has the metaData CLOUD_PIXEL_PERCENTAGE
, and I was hoping I could filter for images less than a certain cloud pixel percentage(say 10-20%). For some reason this returns zero images, no matter the value I use, so I must be using the function incorrectly.
var bands = ['B11','B8','B3'];
var collection = ee.ImageCollection('COPERNICUS/S2').select(bands);
var filtered = collection.
filterBounds(geometry4).
filterDate('2017-05-01','2017-12-01');
var filterClouds
=filtered.filter(ee.Filter.lt('CLOUD_PIXEL_PERCENTAGE',100));
print(filterClouds);
I'm using the ee.Filter.lt
object, which should return images with values that are less than the specified value(100) for the specified metaData(Cloud Pixel Percentage
). I should be returning practically all the images? but I'm returning none...
can I not run ee.Filter.lt
on an ImageCollection
? if so, is there a similar function used for collections?
Upvotes: 0
Views: 4453
Reputation: 7023
The metadata property you need is called CLOUDY_PIXEL_PERCENTAGE
, so you're filtering on a non-existing entry which doesn't return an error, but no results either.
Also, ImageCollection
s have a built-in method, called filterMetadata
which achieves the same result you get, but without the need to specify a ee.Filter
:
var geometry4 = ee.Geometry.Point(-107.42, 36.63)
var bands = ['B11','B8','B3'];
var collection = ee.ImageCollection('COPERNICUS/S2').select(bands);
var filtered = collection
.filterBounds(geometry4)
.filterDate('2017-05-01','2017-12-01');
var filterClouds = filtered
.filterMetadata('CLOUDY_PIXEL_PERCENTAGE','less_than',50);
// returns 21 results
print(filtered.size())
Upvotes: 1