TransWikia.com

In GEE how to select bands for analysis base on availability

Geographic Information Systems Asked on February 15, 2021

I’m trying to use a simple threshold to detect water in Sentinel SAR data. For my application, the VH polarization is more reliable, but I can use the VV polarization if VH is not available. What’s the best way to write code to use the VV band if the VH is not available?
I’ve created a simplified version of my code here to illustrate what I’m trying to accomplish. It involves the problem of mixing server side data with client side processing and using an ‘if’ statement. So,how should something like this be accomplished?

var genWaterMask=function(image,threshold){
    return image.lt(threshold);
  }

var aoi=ee.Geometry.Point(-105.68, 28.12).buffer(9000);
var boundsSet = ee.ImageCollection('COPERNICUS/S1_GRD')
                .filter(ee.Filter.eq('instrumentMode', 'IW')).filterBounds(aoi);

var fall = ee.Filter.date('2015-09-21', '2015-12-20');

var bandName='VH';
var threshold=ee.Number(-10.0);

var fallSet=boundsSet.filter(ee.Filter.listContains(
  'transmitterReceiverPolarisation', bandName)).filter(fall);

if ( fallSet.size() < 1 ){
  var bandName='VV';
  var threshold=ee.Number(-15.0);
  var fallSet=boundsSet.filter(ee.Filter.listContains(
    'transmitterReceiverPolarisation', bandName)).filter(fall);
}

var waterMask=genWaterMask(fallSet.select(bandName).mean(),threshold);

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP