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
print(ui.Chart.feature.byFeature({
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.