0

I have imagecollection from sentinel 1 and I would like to create function that wil calculte new rasters based on a model that I have. my imagecollection called FrostDB and I want to create new imagecollection based on the bands that each image in FrostDB has.

The idea is to: 1. take the two band- VV and VH 2. calculate new band for each image called NRPB ,based on VV and VH 3. take all those 3 bands and calculte new image 4. get new imagecollection which is based on this model.

I have built kind of "draft" for it but I don't know how to tell GEE to take those bands and do it for each image

var model=FrostDB.map(function(im)){
  //////for each image:
  //take the band:  im.VH select('VH_sum');
  //take the band VV im.VH select('VV_sum');
  //Calc  'NRPB': VH.subtract(VV).divide(VH.add(VV)).rename('NRBP')
//take those calculation and for each image calc:
  // '2.13-(-0.5094*VH)+(0.34*VV)+(3.25*NRPB)', {
  //   'VH': imgFrost.select('VH_sum'),
  //   'VV': imgFrost.select('VV_sum'),
  //   'NRPB': VH.subtract(VV).divide(VH.add(VV)).rename('NRBP')
  return im;
});

My end goal: to get new image collection based on the 3 bands (when one of them is calculated also inside the function)

1 Answer 1

1

The mistake you are making in your code is not assigning your variables. Also the curly bracket for your function is misplaced, which however is a syntax error that your compiler should warn you about.

Here's some sample code that should work for your requirements, but please do try to understand what and how it is happening.

var sentinel1 = ee.ImageCollection("COPERNICUS/S1_GRD"),
    geometry = ee.Geometry.Polygon(
        [[[11.828808593749986, 42.33796642590763],
          [11.828808593749986, 41.537083977931076],
          [13.169140624999986, 41.537083977931076],
          [13.169140624999986, 42.33796642590763]]], null, false);

var sampleS1 = sentinel1.filterBounds(geometry)
                        .limit(10)

var calculated = sampleS1.map(function(im){

  // calculate NPRB Band
  var nprb = im.expression(
    'VH - VV / (VH + VV)', {
      'VH': im.select('VH'),
      'VV': im.select('VV')
    }).rename('NPRB')

  // adding NPRB Band to the original Image
  var withNPRB = im.addBands(nprb)

  // Calculating with the NPRB Band
  var result = withNPRB.expression(
      '2.13-(-0.5094*VH)+(0.34*VV)+(3.25*NRPB)', {
      'VH': withNPRB.select('VH'),
      'VV': withNPRB.select('VV'),
      'NRPB': withNPRB.select('NPRB')
    })

  // Only returning result band (other bands are not returned
  // you can add the result just like the nprb band was added if you want to return everything)
  return(result)
})

print(calculated)

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.