0

I'm trying to extract Sentinel 1 VH values for each day of a selected period, and for each polygon of a feature collection:

var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD')
  //filtering by polarisation
                 .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                 //filter by image collected in interferometric wide swath mode
                 .filter(ee.Filter.eq('instrumentMode', 'IW'))
                 //filter by the period
                 .filterDate("2020-12-24","2020-12-28");

var S1_ic = sentinel1.select('VH');

var features = [
  ee.Feature(ee.Geometry.Polygon([
    [11.45721391, 44.04473365],
    [11.45782721, 44.04426541],
    [11.45719584, 44.04382759],
    [11.45690026, 44.04404892],
    [11.45655093, 44.04430347]
    ]), {name: '1'}),
  ee.Feature(ee.Geometry.Polygon([
    [11.45568411, 44.04495992],
    [11.45628790, 44.04450235],
    [11.45565213, 44.04406050],
    [11.45505275, 44.04452208]
    ]), {name: '2'})
  ];
  
var polygons = ee.FeatureCollection(features);
print (polygons)
Map.addLayer(polygons)
Map.centerObject(polygons)
  

var tVH = ee.FeatureCollection(S1_ic.map(function (img) {
  return img.reduceRegions({
    collection: polygons, 
    reducer: ee.Reducer.mean(),
    scale: 10}
    );
})).flatten();

Export.table.toDrive({collection: tVH, folder: 'Export GEE'});

here is the code link: https://code.earthengine.google.com/6b31a91109a92777329249370c739c61.

I'm quite new using GEE and I don't get how to download the data with one single record for each day, instead of having several records for the same day.

1 Answer 1

3

One nice trick that allows obtaining the desired output is converting the ImageCollection to a multiband single image and then apply the reduce regions to this single image. An extra tip: you should apply also a spatial filter to the collection in order to include only images that have information of the region of interest. Here's the code:

var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD')
                 //filtering by polarisation
                 .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                 //filter by image collected in interferometric wide swath mode
                 .filter(ee.Filter.eq('instrumentMode', 'IW'))
                 //filter by the period
                 .filterDate("2020-12-24","2020-12-28")
                 // Filter by polygons
                 .filterBounds(polygons);

var S1_ic = sentinel1.select('VH');
// Convert image collection to a multiband single image
var sentinel1TS = S1_ic.toBands();

var tVH = ee.FeatureCollection(sentinel1TS.reduceRegions({
    collection: polygons, 
    reducer: ee.Reducer.mean(),
    scale: 10})
);


Export.table.toDrive({
  collection: tVH, 
  folder: 'Export GEE',
  description: 'tsVH',
  fileFormat: 'CSV'
});
5
  • Thanks! That's huge. How can I add a column in the output table with the dates of the records? Commented Jul 14, 2021 at 15:36
  • You can extract it from the bands name. It's in format YYYYMMDD. Commented Jul 14, 2021 at 17:01
  • Ok, that's right but here is the problem that I haven't explained before: I made an example with the code above but in reality I have a feature collection of 60 polygons (which is not a problem, it works fine) and a time span for the records of several years. In that case it creates lots of columns for each day. That's why I need a date column along the column of the backscatter values, and possibly only one value for each date. I tried by adding a list of dates to the output feature collection but it doesn't work. Commented Jul 15, 2021 at 8:14
  • You can obtain the desired results by transposing the exported data and extracting the date from each image id's (either by character positions or numeric pattern). That could be easily done in either excel, R, python or similar software. I think that's the easiest approch instead of trying to do that in GEE. Commented Jul 16, 2021 at 1:04
  • Thank you, that works for me! Commented Jul 16, 2021 at 6:10

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.