1

I imported a csv called PADDYPOINTS containing the headers below as a FeatureCollection:

["town","paddy_field","section","longitude","latitude"]

Then, I extracted NDVI values on each point using the .getRegion() function

var PADDYPOINTS = ee.FeatureCollection('users/earthengine/paddy_coordinates');

var dataset = ee.ImageCollection('LANDSAT/LC08/C01/T1_8DAY_NDVI')
  .filterBounds(PADDYPOINTS)
  .filterDate('2017-01-01', '2017-12-31');

var poiArray = dataset.select('NDVI').getRegion(PADDYPOINTS, 30);

However getRegion() only returns coordinates: ["id","longitude","latitude","time","NDVI"] It doesnt return the other columns

How do I join the coordinates from the FeatureCollection above with the getRegion() result to also export the ["town","paddy_field","section"] columns together as one result?

P.S.: I cant seem to join the original csv with the result using python-pandas as the coordinates are not the same anymore after processing

0

1 Answer 1

1

getRegion returns the center latitude/longitude of the pixel being sampled, not the value in the original feature (which might be slightly offset from the center of the pixel), and it's not really the right tool for the job, since it returns a list of pixel values.

You should, instead, use reduceRegions in a function mapped over the imagecollection. That function will return 1 FeatureCollection per input image, so you'll have a collection of collections that will then need to be flattened. If you want the image ID and/or the date, you can map another function over the results of the reduceRegions() to set those on each output feature.

var result = dataset.select('NDVI').map(function(image) {
    return image.reduceRegions(PADDYPOINTS, ee.Reducer.first(), 30)
        .map(function(f) {
            return f.set({id: image.id(), time: image.date().format() })
        })
}).flatten()

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.