3

Is It possible to create .median() Surface Refletance image (landSat 8 RS) without clouds before calculating the NDVI in goolge earth engine? I need to work with a year (eg. 2016-01-01, 2016-12-31), so I need to remove the clouds to create a single image free of clouds and then calculate the NDVI.

1 Answer 1

4

Based on the answer of Mask clouds in LandSat 8 surface refletance image, one possibility is:

NOTE: replace YOUR_PLACE with a Geometry or Feature

// Filter the collection
var col = ee.ImageCollection("LANDSAT/LC8_SR")
          .filterDate("2016-01-01", "2016-12-31")
          .filterBounds(YOUR_PLACE)

// Mask clouds
var col_noclouds = col.map(function(img) {
                   var mask = img.select(['cfmask']).neq(4)
                   return img.updateMask(mask)
                   })

// Median image
var median = ee.Image(col_noclouds.median())

// NDVI
var median_ndvi = median.normalizedDifference(['B4', 'B5'])
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.