Google Earth Engine – Extracting Band Values from Image Collection over Point Shapefile

google-earth-enginereduceregionvalue-extraction

I have an image collection in GEE consisting of 36 images, each with 23 bands of Sentinel 2 data (S2L2A).

I also have a point shapefile that I imported as an asset (RAEJORDANESIA_POINT).

I want to extract band values in these points and make a chart of it.
I wrote this script:

var RAEJORDANESIA_POINT = ee.FeatureCollection('users/parivash89/Eucalyptus_Brazil/RAE_JORDANESIA_1_2_arvores_perigosas_POINTS');
Map.addLayer(RAEJORDANESIA_POINT, {color: '#e73400',strokeWidth: 10}, 'RAEJORDANESIA_POINT');

var START = ee.Date('2021-11-01');
var FINISH = ee.Date('2022-04-29');

var ImageCollection = S2L2A
.filterDate(START,FINISH)
.filterBounds(RAEJORDANESIA_POINT);

Map.addLayer(ImageCollection, {min:0,max:3000,bands:"B4,B3,B2"}, 'ImageCollection');
print(ImageCollection)

var params = {
  reducer: ee.Reducer.median(),
  scale: 10,
  crs: 'EPSG:4326',
  bands: ['B6', 'B7', 'B8', 'B8A'],
  bandsRename: ['red-edge2', 'red-edge3', 'NIR', 'red-edge4']
};

// Extract zonal statistics per point per image.
var ptsStats = zonalStats(ImageCollection, RAEJORDANESIA_POINT, params);
print(ptsStats);

I found this script from https://developers.google.com/earth-engine/tutorials/community/extract-raster-values-for-points

I get the error:

Line 25: zonalStats is not defined

I also tried using reduceRegions:

var vals = ImageCollection.reduceRegions({
    collection: RAEJORDANESIA_POINT,
    reducer: 'mean',
    scale: 10, 
  })

print(vals)

And I got the error:

Line 33: ImageCollection.reduceRegions is not a function

Here is the link with shared point asset enter link description here

How can I extract all band values (mostly I am interested in NIR and red-edge bands) in these point and make a chart out of it for each point?

Best Answer

If you want to export the data, you can select the features you need in this way:

Export.table.toDrive({ collection: ptsStats, 
    description:'ExtractedValuesofPoints', 
    fileFormat: 'CSV', 
    selectors: (['red-edge2', 'red-edge3', 'NIR', 'red-edge4', 'datetime', '.geo'])})

The problem with empty file comes from selecting columns that don't exist (you use in the script bandsRename: ['red-edge2', 'red-edge3', 'NIR', 'red-edge4'] to rename ['B4', 'B5', 'B6', 'B7', 'B8']. Therefore, you need to use new band names in your export).

Also, I would recommend adding a date column too, as it may be helpful for your further analysis.

I hope this helps.

Related Question