1

I need to extract the values at each pixel foe a feature collection from an image and if they are masked the value at nearest pixel, my feature collection is named table and the image collection I am using is Landsat 7 Collection 1 Tier 1 Annual NDVI Composite

var mapfunc = function(feat) {
 var geom = feat.geometry()
 var addProp = function(img, f) {
   var newf = ee.Feature(f)
   var date = img.date().format()
   var value = img.reduceRegion(ee.Reducer.first(), geom, 30).get("NDVI")
   return ee.Feature(ee.Algorithms.If(value,
                                  newf.set(date, ee.String(value)),
                                  newf.set(date, ee.String('No data'))))
  }
  var newfeat = ee.Feature(ndvi.iterate(addProp, feat))
  return newfeat
 };

 var newftNDVI = table.map(mapfunc);

This code extracts values at said pixels but does not extract the nearest pixel values for the masked ones.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.