1

I uploaded a shapefile of some points, and I want to extract backscatter values from that points. When I do it, I can't recognize them in the chart using ui.Chart.image.regions.

Each point is called as undefined in the plot, instead of its shapefile ID. I can't relate backscatter with the point position.


//This is my script. 
var AOI = ee.FeatureCollection("users/PIJ-17-05/Humedal_Pugllohuma7"); //AVAILABLE SHAPES
var drenaje = ee.FeatureCollection("users/PIJ-17-05/Drenaje_Principal"); //AVAILABLE SHAPES

//Define Wetland Validation Zones
var pozos = ee.FeatureCollection("users/PIJ-17-05/pozos"); //AVAILABLE SHAPES 
print(pozos);
//Load Sentinel-1 SAR collection and filter according to data collection type
var image = ee.ImageCollection('COPERNICUS/S1_GRD')
  .filterBounds(AOI)
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
  .filterMetadata('resolution_meters', 'equals' , 10);

//Create DATE Filters
var jun_17 = ee.Filter.date('2017-06-16','2017-06-26');//Se busca 21/06/2017 Se obtuvo 19/06/2017
var jul_17= ee.Filter.date('2017-07-12','2017-07-26');//Se busca 19/07/2017 Se obtuvo 13/07/2017 y 25/07/2017 
var ago_17 = ee.Filter.date('2017-08-19','2017-08-29');//Se busca 24/08/2017 Se obtuvo 28/08/2017
var ene_18= ee.Filter.date('2018-01-04','2018-01-14');//Se busca 09/01/2018 Se obtuvo 09/01/2018
var may_18 = ee.Filter.date('2018-05-18','2018-05-28');//Se busca 23/05/2018 Se obtuvo 19/05/2018 y 21/05/2018
var jun_19 = ee.Filter.date('2019-06-16','2019-06-26');//Se busca 21/06/2019 Se obtuvo 21/06/2019

var allSeasonsFilter = ee.Filter.or(jun_17,jul_17,ago_17,ene_18,may_18,jun_19); // Create joint Filter

var allSeasons = image.filter(allSeasonsFilter);

print(allSeasons);

//Make time series of water pixels within region
var ClassChart = ui.Chart.image.series({
  imageCollection: allSeasons.select('VV'),
  region: AOI,
  reducer: ee.Reducer.count(),
})
  .setOptions({
      title: 'VV Pixels',
      hAxis: {'title': 'Date'},
      vAxis: {'title': 'Number of Pixels'},
      lineWidth: 2
    })

//Set the postion of the chart and add it to the map    
ClassChart.style().set({
    position: 'bottom-right',
    width: '500px',
    height: '300px'
  });

Map.add(ClassChart);

// Create a label on the map.
var label = ui.Label('Click a point on the chart to show the image for that date.');
Map.add(label);

//Create callback function that adds image to the map coresponding with clicked data point on chart
ClassChart.onClick(function(xValue, yValue, seriesName) {
    if (!xValue) return;  // Selection was cleared.

    // Show the image for the clicked date.
    var equalDate = ee.Filter.equals('system:time_start', xValue);
    //Find image coresponding with clicked data and clip water classification to roi 
    var classification = ee.Image(allSeasons.filter(equalDate).first()).clip(AOI).select('VV'); 
    var SARimage = ee.Image(allSeasons.filter(equalDate).first());
    //Make map layer based on SAR image, reset the map layers, and add this new layer
    var S1Layer = ui.Map.Layer(SARimage, {
      bands: ['VH'], //choose a different band than the interest one
      max: 0,
      min: -20
    });
    Map.layers().reset([S1Layer]);
    var visParams = {
      min: -10,
      max: -14,
      palette: ['#FFFFFF','#0000FF']
    }
    //Add water classification on top of SAR image
    Map.addLayer(classification,visParams,'VV')

    // Show a label with the date on the map.
    label.setValue((new Date(xValue)).toUTCString());
    //Map Pozos
    Map.addLayer(pozos, {color: 'black'} , 'Pozos');
    //Drenaje
    Map.addLayer(drenaje, {color: '#2fced6'} , 'Drenaje');
  });

//First date analysis
var listOfImages = allSeasons.toList(allSeasons.size());
var selection = listOfImages.get(0);
var S1 = ee.Image(selection);
print(S1);
// Pre-define some customization options.
var options = {
  title: 'Sentinel 1 histogram',
  fontSize: 20,
  hAxis: {title: 'backscatter'},
  vAxis: {title: 'count of distribution'},
  series: {
    0: {color: 'blue'},
    1: {color: 'green'},
    2: {color: 'red'}}};

// Make the histogram, set the options.
var histogram = ui.Chart.image.histogram(S1, AOI, 30)
    .setSeriesNames(['VV', 'VH', 'angle'])
    .setOptions(options);

// Display the histogram.
print(histogram);
var names = ee.List.sequence(1, 18);
//Creates the scatter chart
var Chart1 = ui.Chart.image.regions(S1, pozos, ee.Reducer.mean(), 10,'label')
.setChartType('ScatterChart')
.setOptions({
          title: 'Retrodispersión Registrada en Pozos del Humedal Pugllohuma',
          vAxis: {title: 'Retrodispersión (dB)'},
          pointSize: 4});
print(Chart1)


Map.addLayer(S1.select('VH'), {min: -26, max: -23, palette:['blue','green']}, 'VH');
Map.addLayer(S1.select('VV'), {min: -14, max: -10, palette:['blue','green']}, 'VV');

Map.addLayer(AOI, {}, 'AOI')
Map.centerObject(AOI, 16.5) //Specify the zoom magnitude

//Map Pozos
Map.addLayer(pozos, {color: 'white'} , 'Pozos');
//Drenaje
Map.addLayer(drenaje, {color: '#2fced6'} , 'Drenaje');

3
  • Can you be more specific with your question? It isn't clear whether you can't find something in your plot, or if GEE can't find something you want to plot. Since your feature collection isn't accessible it's difficult to replicate your issue. Commented Oct 28, 2019 at 18:31
  • Sure, when I plot the information each point has the name "undefined" instead of the shapefile ID. Commented Oct 28, 2019 at 18:56
  • I want to know the ID of the point to relate its backscatter with the coordinates. Commented Oct 28, 2019 at 18:59

1 Answer 1

1

You are using the wrong function, ui.Chart.image.regions are only going to give you data in series. You should be using reduceRegions (or since your shapes are points you can use sampleRegions as well)

S1.reduceRegions({
  collection:pozos, 
  reducer:ee.Reducer.mean(), 
  scale:10});

should give you what you want.

1

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.