this is my very first time working with the GEE and I have tried now for over 2 weeks to write my own code for this, but I'm pretty desperate with it - it just doesn't work.

I have a shape file with ~4000 defined points all over Europe. Each point has a unique point_id. I want to extract the pixel values of an image at these defined points (to make it easy I tried it with the Forest Non-Forest map on GEE https://developers.google.com/earth-engine/datasets/catalog/JAXA_ALOS_PALSAR_YEARLY_FNF). To connect the extracted pixel values later with my main data in R, I wanted to export it together with the associated point_ids (key variable) as a .csv table.

If this is for any use, here is one of my many attempts:

//loading data: 
// --> dataset = forestNonForest image from GEE
// --> sapled_points = my shape file with the points and poin_id for each point. Imported to the GEE script from the assets in GEE
var dataset = ee.ImageCollection('JAXA/ALOS/PALSAR/YEARLY/FNF')
                  .filterDate('2017-01-01', '2017-12-31');

var forestNonForest = dataset.select('fnf');

var forestNonForestVis = {
  min: 1.0,
  max: 3.0,
  palette: ['006400', 'FEFF99', '0000FF'],

var image = dataset.first();

//Extracting values
var sampled_points = image.sampleRegions({ //--> or should I use 'reduceRegions'? If that makes more sence, what would the code look like for  'reduceRegions'?
  collection: points,
  scale: 30,
  geometries: true

print(sampled_points, 'ForestValues');

//drawing chart to download CSV values
  features: sampled_points,
  yProperties: ['fnf'] // --> how can I add the associated point_id from my shape file here, so I can download it from the created chart?

Map.centerObject(sampled_points, 3);
Map.addLayer(sampled_points, {color: 'blue'}, 'sampled');

The problem with this one is, that I can't connect / join the .csv table to my main data in R, bacause there is no key variable (which would be the point_id) in the created GEE table.

Although this is probably pretty easy, I have a hard time doing it. Unfortunately, the solutions of similar problems in this platform didn't work for me.

1 Answer 1


I think you only need these lines in your code for connecting point_ids to fnf property in respective CSV file:

// Export features, specifying corresponding names.
"sampled_points", //my task
"GEE_Folder", //my export folder
"sampled_points",  //file name

Complete code is here.

For testing my approach I generated arbitrarily 18 point over Europe and this multi point geometry was named as your points variable.

After running complete code in GEE code editor, it was obtained following result:

enter image description here

CSV associated file, obtained after running corresponding task, looks as follows:

enter image description here

It can be observed the associated point_ids (key variable) with corresponding fnf property and point geometry.


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.