1

I trying to plot the mean of the pixel values that the buffer contains over the given period, but I'm unable to get the mean of pixel values. The link to the code that I wrote is provided below.

Map.addLayer(Bhagwanpur, {}, 'Bhagwanpur', false)
Map.centerObject(Bhagwanpur, 12)
            
Map.addLayer(GT, {}, 'March GT', false)

var CreateBuffer = function(feature, buffer_size) {
  return feature.buffer(buffer_size)
  }

var buffer_size= 10

var GT_Buffer = GT.map(function(ft){return CreateBuffer(ft, buffer_size)});
Map.addLayer(GT_Buffer, {}, 'GT_Buffer')
Map.centerObject(GT_Buffer, 15)
print('GT_Buffer',GT_Buffer)


              /*---------------------------X-------------------------------------*/


// Importing the Sentinel-1 Images:
var S1= ee.ImageCollection("COPERNICUS/S1_GRD")
          .filterDate('2021-05-01', '2022-07-15')
          .filterBounds(Bhagwanpur)
          .select (['VV','VH'])
          .filter(ee.Filter.eq('instrumentMode', 'IW'))
print('S1',S1)


var addVVbyVH = function(image) {
  var vv = image.select('VV');
  var vh = image.select('VH');
  var VVbyVH = (vv).divide(vh).rename('VVbyVH');
  return image.addBands(VVbyVH);
};

var S1 = S1.map(addVVbyVH);
print(S1)


        /*--------------------------------------X--------------------------------------------*/


//Visualization of Images: 
Map.addLayer(S1.first().clip(Bhagwanpur), {'min': [-25, -20, 0], 'max': [5, -10, 5]}, 'S1 RGB', false)


        /*--------------------------------------X--------------------------------------------*/


var chartvv = ui.Chart.image.seriesByRegion(
     S1,
     GT_Buffer.filter(ee.Filter.eq('Field_ID', 5)),
    ee.Reducer.mean(),
    'VV',10)
var chartv2 = chartvv.setSeriesNames(['VV'])
        .setChartType('LineChart') 
        .setOptions({
          title: 'Sentinel-1 time series',
          hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'dB values',
            titletext style: {italic: false, bold: true}
          },
          lineWidth: 5,
          colors: ['#fc0303', '#17fc03','#0324fc'],
          curveType: 'function'
        });
        
print(chartv2)

Code: https://code.earthengine.google.co.in/b84ae0181646d5d539e830fd28b55bc7

1 Answer 1

1

As your assets are not available, I had to create them as follows:

var Bhagwanpur = ee.Geometry.Point (76.8576, 29.5632);
var GT = ee.FeatureCollection(Bhagwanpur); 

Afterward, I found out that the issue was in the filter in chartvv variable.

var chartvv = ui.Chart.image.seriesByRegion(
     S1,
     GT_Buffer.filter(ee.Filter.eq('Field_ID', 5)),
    ee.Reducer.mean(),
    'VV',10);

I changed it in following way:

var chartvv = ui.Chart.image.seriesByRegion(
     S1,
     GT_Buffer,//GT_Buffer.filter(ee.Filter.eq('Field_ID', 5)),
    ee.Reducer.mean(),
    'VV',10);

and, after running complete code in GEE code editor, I got printed the corresponding chart as follows. So, you need to filter your buffer geometry in a valid way.

enter image description here

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.