1

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?

8
  • Thanks @user2856. I added the function and now I got error:FeatureCollection (Error) Collection query aborted after accumulating over 5000 elements. Here is the new link: code.earthengine.google.com/adae07f337f8b251dbe9cfa20547c542
    – Paris
    Apr 29, 2022 at 9:10
  • I have add params: var params = { reducer: ee.Reducer.median(), scale: 10, crs: 'EPSG:4326', bands: ['B4', 'B5', 'B6', 'B7', 'B8'], bandsRename: ['red-edge1','red-edge2', 'red-edge3', 'NIR', 'red-edge4'] };
    – Paris
    Apr 29, 2022 at 10:02
  • I do not want to print or even export all bands and properties. I am just interested in these 5 bands
    – Paris
    Apr 29, 2022 at 10:03
  • I deleted the print function and I tried to use Export to drive as follows:
    – Paris
    Apr 29, 2022 at 10:03
  • 1
    All good comments! I would just add @user2856 that the number of features is calculated 36 images * 269 points. If it's more than 5000, you get an error. If it's 4999 - it will work. Number of bands does not matter. Other than that - really helpful insights. Apr 29, 2022 at 18:34

1 Answer 1

1

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.

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.