Convert Sentinel-1 images data from dB to linear

google-earth-enginesentinel-1

I would like to use speckle lee refined filter on Sentinel-1 collection. But in every document I found, it says that the input should be linear not in dB. Normally S-1 data in GEE is in dB.

How do I convert it to linear?

Couldn't find any code for that.

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()

// How do I covert db to linear?

Map.addLayer(db, {bands: 'VV,VH,VV', min: -25, max: 0})  

https://code.earthengine.google.com/e9c1de10f5b32f56f8a3857ebbadc4c5

Best Answer

You can covert an S1 image in db to linear with this:

ee.Image().expression('pow(10, db / 10)', {
  db: db.select(['VV', 'VH'])
})

However, there are two image collections with S1 imagery, and one of them (COPERNICUS/S1_GRD_FLOAT) already comes in linear. Here's a complete example showing conversion back and forth from db to linear:

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,VH,VV', min: -25, max: 0})  
Map.addLayer(toDb(linear), {bands: 'VV,VH,VV', min: -25, max: 0})
Map.addLayer(toDb(toLinear(db)), {bands: 'VV,VH,VV', min: -25, max: 0})  

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

https://code.earthengine.google.com/a57f1bef88f429abe73529844d219ae8

Related Question