Skip to main content

Hi! I added a new layer which Source is Sentinel S1 GRD and we need to use VH in decibels from -23 to -14 db but now it returns values from -20 to 0 I think (//displays VH in decibels from -20 to 0). This is the code we are using:


var val = [Math.max(0, Math.log(VH) * 0.21714724095 + 1)];

var valaux = 13.146*(val) + 317.45;

return colorBlend(valaux,[0,40],[[1,1,0],[0,0,1]]);


Is there a way to get VH in decibels from -23 a -14?


Thanks!

Hi,

The VH linear to decibel conversion formula of which you are probably aware is below:


// displays VH in decibels from -20 to 0

// the following is simplified below

// var log = 10 * Math.log(VH) / Math.LN10;

// var val = Math.max(0, (log + 20) / 20);

var val = [Math.max(0, Math.log(VH) * 0.21714724095 + 1)];


This will visualize values from -20 to 0 decibels, values less than -20 that will be black and more than 0 white. (The script doesn’t actually return values between -20 and 0).


To change the displayed range this needs a bit of modification.

// var log = 10 * Math.log(VH) / Math.LN10;

This line is the same as it is the actual conversion.


Next you need to fit these values between 0 and 1 so it will get visualized correctly.

The general formula is:

// var min

// var max

// var val = Math.max(0, log - min) / (max - min));

This visualizes values between min and max.


In your case min = -23, max = -14, so:

// var val = Math.max(0, (log - -23) / (-14 - -23);

this simplifies to (you don’t actually need this step but it makes it a little faster):

var val = lMath.max(0, Math.log(VH) * 0.11111111111 + 2.55555555556)];


Thanks Marko! In this case:

var val = [Math.max(0, Math.log(VH) * 0.11111111111 + 2.55555555556)];

The variable val returns values from -23 to -14? Or what values does the variable take?

Thanks!


Hi Leonardo,

in this case the variable returns values between 0 and 1 so it gets visualized correctly. (0 goes to black, 1 to white). But if you need the actual decibel values for further processing for example, then this is not necessary. You can then use the log variable instead which takes exact values:

var log = 10 * Math.log(VH) / Math.LN10;


If you want values only between -23 and -14 (so anything less than -23 goes to -23, anything more than -14 goes to -14) you can use:

var val = Math.max(Math.min(log, -14), -23);


Hi Marko, the script we are using is:

var val = Math.max(Math.min(log, -14), -23);

var valaux = 13.146*(val) + 317.45;

return colorBlend(valaux,[0,19730],[[1,1,0],[0,0,1]]);


How do I colored the map from yellow to blue:

valaux returns 15,092 if val is -23 and 133,406 if val -14.

We tried the colorBlend function in different ways but we couldn’t make it work.

Thanks!


Try:


var log = 10 * Math.log(VH) / Math.LN10;

return colorBlend(log, [-23,-14], [[1,1,0],[0,0,1]]);


Hi Marko, is there a way to use “transparent” color when we use colorBlend, I mean, to see some transparent pixels on the layer instead of a solid color from some value 1 to a value 2 and then use solid colors.

Thanks


Reply