1

I have a fusion table and it content several points. I have also created NDVI layer. Now i need to print NDVI value of individual pixels associated with point ids(taken from fusion table). But i don't know how to do that. To track the point id of fusion table i tried to print point features. I have written the following codes for the same. Console pictures is attached to which ids i want to get.Also sharing the GEE linkCode link [Exmp: [Need to know the ndvi value for id 3]]

    // ---------Cloud Masking function

function maskS2clouds(image) {
  var qa = image.select('QA60');

  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = ee.Number(2).pow(10).int();
  var cirrusBitMask = ee.Number(2).pow(11).int();

  // Both flags should be set to zero, indicating clear conditions
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(
             qa.bitwiseAnd(cirrusBitMask).eq(0));

  // Return the masked and scaled data.
  return image.updateMask(mask).divide(10000);
}



var boundary = ee.FeatureCollection('ft:1T-XrxMki2k49fhQdhMxesWKBoyyUJiKN70pErh9z');// Boundary
var gtpoints = ee.FeatureCollection('ft:1ZvFeFO5jHGo3VExlKNc-kdL-3hmJSeyfLzqLvHhy');//Co-ordinates
print(gtpoints);
var test = gtpoints.features;
print(test);
Map.centerObject(boundary);
// ---------  Import of Images (Sentinel _ 2 multispectral)


var image = ee.ImageCollection(sent2img
.filterDate("2018-09-22","2018-10-23")
.filterBounds(boundary)
.map(maskS2clouds)
.sort("CLOUD_COVERAGE_ASSESSMENT")
.median()
);

//----------  Preprocessing 

var mosaic = image.mosaic()
var clip = mosaic.clip(boundary);
print('clip', clip);


//----------   FCC creation and visualisation of AOI     
Map.addLayer(clip, {bands: ['B8','B4','B3'], min: 0, max: 0.3},'clip');


var ndvi = clip.expression(
    ' ((NIR - RED) / (NIR + RED))', {
      'NIR': clip.select('B8'),
      'RED': clip.select('B4'),
}).rename('nd');

var palette = ['196fda', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
               '74A901', '66A000', '529400', '3E8601', '207401', '056201',
               '004C00', '023B01', '012E01', '011D01', '011301'];

Map.addLayer(ndvi, {min:0, max:1, palette: palette},"NDVI");  
7
  • Hi Avik. What have you tried? You should post some code so we can see what you're trying to do and how to help you. Oct 23, 2018 at 14:10
  • shared my half done code,
    – Avik Betal
    Oct 23, 2018 at 14:23
  • 1
    @AvikBetal Please edit your question with the additional information. Comments are considered "non permanent" and new information should be added to the question itself.
    – Kersten
    Oct 23, 2018 at 14:36
  • You don't have to post the entire code if you don't want, you could just post a sample code to reproduce the error or the task you are having trouble with Oct 23, 2018 at 15:43

2 Answers 2

2

Add this code to the sample code to get each point ndvi:

// Get NDVI in each point
var points_ndvi = ndvi.reduceRegions({
  collection: gtpoints,
  reducer: ee.Reducer.first(),
  scale: 10
})

// Rename
var properties = ee.Feature(points_ndvi.first()).propertyNames()
var new_names = properties.replace('first', 'ndvi')
points_ndvi = points_ndvi.select(properties, new_names)

// You can export it as a table
// Export.table.toDrive(points_ndvi, 'description', 'folder', 'fileNamePrefix', 'CSV')

// Pretty Print
var points_list = points_ndvi.toList(points_ndvi.size())
var points_ids = points_list.map(function(ft) {return ee.String(ee.Feature(ft).id())})
var points_values = points_list.map(function(ft) {return ee.String(ee.Feature(ft).get('ndvi'))})

print(ee.Dictionary.fromLists(points_ids, points_values))

https://code.earthengine.google.co.in/c78a6e70c646eb9cdec149657cb839f6

1

Red color showing the function i used

I used the following function : filter(ee.Filter.metadata(...))

Your Answer

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

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