I have 21 polygons and for each polygon I want to extract the pixel values inside them for Sentinel 1 images from 2017-01-01 to 2017-06-30.

The example below shows how this is done for one polygon. I want this for 21 polygons. Extract complete pixel values inside a geometry

My expected output is a csv with columns polygon name, lat, lon, VH, VV and system:time start dates.

This is what I have so far.

//Location Data
var test= loc;
Map.centerObject( test, 10);

var pol = ['VV', 'VH']; 
//Load Sentinel1 image location around location 1
var Sentinel1= S1.filter(ee.Filter.eq('transmitterReceiverPolarisation', pol))
                    .filterMetadata('instrumentMode', 'equals', 'IW')
                    .filterDate('2017-01-01', '2017-06-30')
                    .select(['VH', 'VV'])
                    .filterMetadata('resolution_meters', 'equals' , 10).first();

Map.addLayer(Sentinel1, imageVisParam, 'single_image');

// generate a new image containing lat/lon of the pixel and reproject it to Sentinel1 projection
var coordsImage = ee.Image.pixelLonLat().reproject(Sentinel1.projection())
var joinedImage = coordsImage.addBands(Sentinel1);

// extract lat/lon coordinates as a list
var newfc= test.map(function(feat){
var coords = joinedImage.reduceRegion({
  reducer: ee.Reducer.toList(4), 
  geometry: feat.geometry(),
  scale: 10


coords = ee.List(coords)

//Export as CSV
var myFeatures = ee.FeatureCollection(coords.map(function(el){
  el = ee.List(el) // cast every element of the list
  var geom = ee.Geometry.Point([ee.Number(el.get(0)), ee.Number(el.get(1))])
  return ee.Feature(null, {'VH':ee.Number(el.get(2)), 'VV':ee.Number(el.get(3)),


return myFeatures

var table= newfc.flatten()


// Export the image, specifying scale and region.
// Export the FeatureCollection.
  collection: table,
  description: 'TRIAL',
  fileFormat: 'CSV'


Link to locations table: https://code.earthengine.google.com/?asset=users/rawailnaeem/test

Right now it is working fine for 1 image. I need this for each image in the imageCollection, not a mosaic image. So basically my question is how to loop this function over the entire image collection?

  • Please, explain better (in this post) what are you trying to do, what is the expected result, what works and what does not. And also add the code in the post (leave the link as well) Commented Sep 3, 2018 at 20:48
  • @RodrigoE.Principe I have added the full description. I hope it makes sense now. Thank you Commented Sep 4, 2018 at 6:07
  • @RodrigoE.Principe any luck with this one? The code is working fine for a single image. I just need to include a function so it gets images from the image collection. Commented Sep 5, 2018 at 10:41
  • Hi, sorry, I haven't had the time to look at it Commented Sep 5, 2018 at 18:42

1 Answer 1


The comment by @Rodrigo E. Principe is probably what you are looking for.

You basically go through each feature with the .map(myFunction) and then in myFunction you iterate through the image collection.

Extracting pixel values by points and converting to table in Google Earth Engine?

  • Can't get it right. Can yo please show how it can be implemented on this code? Commented Sep 17, 2018 at 11:03

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.