2

I am working only on VV polarization of Sentinel-1 Images. Wanted to use the function from other answer (Convert Sentinel-1 images data from dB to linear) but it doesn't seem to work when given only VV. Why is that? How do I make it work when having only 1 band? Please be aware that originally image has 3 bands, so I really don't understand that behaviour. Here's the test code:

var filter = ee.Filter.and(
  ee.Filter.bounds(Map.getBounds(true)),
  ee.Filter.date('2022-01-01', '2022-02-01')
)

var db = ee.ImageCollection('COPERNICUS/S1_GRD')
  .filter(filter)
  .mosaic()

var linear = ee.ImageCollection('COPERNICUS/S1_GRD_FLOAT')
  .filter(filter)
  .mosaic()

    
Map.addLayer(db, {bands: 'VV', min: -25, max: 0}, 'DB')
Map.addLayer(linear, {bands: 'VV', min: -25, max: 0}, 'LINEAR')  
Map.addLayer(toDb1(linear), {bands: 'VV', min: -25, max: 0}, 'AFTER DB1') // THIS WORKS
Map.addLayer(toDb2(linear), {bands: 'VV', min: -25, max: 0}, 'AFTER DB2') // THIS DOES NOT

  

function toDb1(linear) {
  return linear.addBands(
    ee.Image().expression('10 * log10(linear)', {
      linear: linear.select(['VV', 'VH']) // VV and VH
    }),
    null, true // Replace the bands to keep image properties
  )
}

function toDb2(linear) {
  return linear.addBands(
    ee.Image().expression('10 * log10(linear)', {
      linear: linear.select(['VV']) // only VV
    }),
    null, true // Replace the bands to keep image properties
  )
}

Link to the code: https://code.earthengine.google.com/f3656ddfd179f7559c7425e96e913faf

1 Answer 1

1

This is expression() behaving a bit inconsistent. In the multi-band case, your resulting bands are named after the input. When you have a single band, your result is constant. Manually rename the output and you're good.

  return linear.addBands(
    ee.Image().expression('10 * log10(linear)', {
      linear: linear.select(['VV'])
    }).rename('VV'),
    null, true // Replace the bands to keep image properties
  )

https://code.earthengine.google.com/388031402ec8e54e6161bde02cc108a8

1
  • wow thank You it worked Dec 19, 2022 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.