Skip to content

Commit

Permalink
Merge pull request #301 from dipankar05/patch-1
Browse files Browse the repository at this point in the history
Update script.js
  • Loading branch information
chorng authored Feb 13, 2024
2 parents d549310 + ab5c53d commit d826f50
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sentinel-1/radar_vegetation_index/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ examples:
platform:
- CDSE
- EOB
evalscript: Ly9WRVJTSU9OPTMKZnVuY3Rpb24gc2V0dXAoKSB7CiAgICByZXR1cm4gewogICAgICAgIGlucHV0OiBbIlZWIiwgIlZIIiwgImRhdGFNYXNrIl0sCiAgICAgICAgb3V0cHV0OiBbCiAgICAgICAgICAgIHsgaWQ6ICJkZWZhdWx0IiwgYmFuZHM6IDQgfSwKICAgICAgICAgICAgeyBpZDogImluZGV4IiwgYmFuZHM6IDEsIHNhbXBsZVR5cGU6ICJGTE9BVDMyIiB9LAogICAgICAgICAgICB7IGlkOiAiZW9icm93c2VyU3RhdHMiLCBiYW5kczogMSwgc2FtcGxlVHlwZTogJ0ZMT0FUMzInIH0sCiAgICAgICAgICAgIHsgaWQ6ICJkYXRhTWFzayIsIGJhbmRzOiAxIH0KICAgICAgICBdCiAgICB9Owp9Cgpjb25zdCByYW1wID0gWwogICAgWzAsIDB4OGUwMTUyXSwKICAgIFswLjI1LCAweGRlNzdhZV0sCiAgICBbMC41LCAweGY3ZjdmN10sCiAgICBbMC43NSwgMHg3ZmJjNDFdLAogICAgWzEsIDB4Mjc2NDE5XSwKXTsKCgpjb25zdCB2aXN1YWxpemVyID0gbmV3IENvbG9yUmFtcFZpc3VhbGl6ZXIocmFtcCk7CgpmdW5jdGlvbiBldmFsdWF0ZVBpeGVsKHNhbXBsZXMpIHsKICAgIGxldCBkb3AgPSAoc2FtcGxlcy5WViAvIChzYW1wbGVzLlZWICsgc2FtcGxlcy5WSCkpOwogICAgbGV0IG0gPSAxIC0gZG9wOwogICAgLy9kZXBvbGFyaXphdGlvbiB3aXRoaW4gdGhlIHZlZ2V0YXRpb24KICAgIGxldCB2YWwgPSAoTWF0aC5zcXJ0KGRvcCkpICogKCg0ICogKHNhbXBsZXMuVkgpKSAvIChzYW1wbGVzLlZWICsgc2FtcGxlcy5WSCkpOwogICAgLy8gVGhlIGxpYnJhcnkgZm9yIHRpZmZzIHdvcmtzIHdlbGwgb25seSBpZiB0aGVyZSBpcyBvbmx5IG9uZSBjaGFubmVsIHJldHVybmVkLgogICAgLy8gU28gd2UgZW5jb2RlIHRoZSAibm8gZGF0YSIgYXMgTmFOIGhlcmUgYW5kIGlnbm9yZSBOYU5zIG9uIGZyb250ZW5kLgogICAgY29uc3QgaW5kZXhWYWwgPSBzYW1wbGVzLmRhdGFNYXNrID09PSAxID8gdmFsIDogTmFOOwogICAgY29uc3QgaW1nVmFscyA9IHZpc3VhbGl6ZXIucHJvY2Vzcyh2YWwpOwoKICAgIHJldHVybiB7CiAgICAgICAgZGVmYXVsdDogaW1nVmFscy5jb25jYXQoc2FtcGxlcy5kYXRhTWFzayksCiAgICAgICAgaW5kZXg6IFtpbmRleFZhbF0sCiAgICAgICAgZW9icm93c2VyU3RhdHM6IFt2YWxdLAogICAgICAgIGRhdGFNYXNrOiBbc2FtcGxlcy5kYXRhTWFza10KICAgIH07Cn0K
evalscripturl: https://custom-scripts.sentinel-hub.com/sentinel-1/radar_vegetation_index/eob.js
---

## General description of the script
Expand Down
20 changes: 16 additions & 4 deletions sentinel-1/radar_vegetation_index/eob.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,27 @@ const ramp = [
const visualizer = new ColorRampVisualizer(ramp);

function evaluatePixel(samples) {
let dop = (samples.VV / (samples.VV + samples.VH));
let m = 1 - dop;
//equivalent to complement of the degree of polarization
// Ratio parameter
let q = (samples.VH / samples.VV);

// co-pol purity parameter m
// m = (1-q)/(1+q)
// normalized co-pol intensity parameter beta
// beta = 1/(1+q)
// Dual-pol radar vegetation indec DpRVIc = 1-(m*beta)
// It can be also written directly in terms of q as follows
let N = q*(q+3);
let D = (q+1)*(q+1);

//depolarization within the vegetation
let val = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH));
//let val = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH));
let val = N/D;

// The library for tiffs works well only if there is only one channel returned.
// So we encode the "no data" as NaN here and ignore NaNs on frontend.
const indexVal = samples.dataMask === 1 ? val : NaN;
const imgVals = visualizer.process(val);

return {
default: imgVals.concat(samples.dataMask),
index: [indexVal],
Expand Down
17 changes: 14 additions & 3 deletions sentinel-1/radar_vegetation_index/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ function setup() {

function evaluatePixel(samples) {
//equivalent to complement of the degree of polarization
let dop = (samples.VV / (samples.VV + samples.VH));
let m = 1 - dop;
// Ratio parameter
let q = (samples.VH / samples.VV);

// co-pol purity parameter m
// m = (1-q)/(1+q)
// normalized co-pol intensity parameter beta
// beta = 1/(1+q)
// Dual-pol radar vegetation indec DpRVIc = 1-(m*beta)
// It can be also written directly in terms of q as follows
let N = q*(q+3);
let D = (q+1)*(q+1);

//depolarization within the vegetation
let value = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH));
//let value = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH));
let value = N/D;
return [value]
}
18 changes: 15 additions & 3 deletions sentinel-1/radar_vegetation_index/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Radar vegetation index for Sentinel-1 (RVI4S1) SAR data
// Institute: MRSLab, Indian Institute of Technology Bombay, India
// Data requirements: Sentinel-1 GRD data
// Reference: Bhogapurapu, N., Dey, S., Mandal, D., Bhattacharya, A., Karthikeyan, L., McNairn, H. and Rao, Y.S., 2022. Soil moisture retrieval over croplands using dual-pol L-band GRD SAR data. Remote Sensing of Environment, 271, p.112900.
function setup() {
return {
input: ["VV", "VH", "dataMask"],
Expand All @@ -20,10 +21,21 @@ const visualizer = new ColorRampVisualizer(ramp);

function evaluatePixel(samples) {
//equivalent to complement of the degree of polarization
let dop = (samples.VV / (samples.VV + samples.VH));
let m = 1 - dop;
// Ratio parameter
let q = (samples.VH / samples.VV);

// co-pol purity parameter m
// m = (1-q)/(1+q)
// normalized co-pol intensity parameter beta
// beta = 1/(1+q)
// Dual-pol radar vegetation indec DpRVIc = 1-(m*beta)
// It can be also written directly in terms of q as follows
let N = q*(q+3);
let D = (q+1)*(q+1);

//depolarization within the vegetation
let value = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH));
//let value = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH));
let value = N/D;
let imgVals = visualizer.process(value);
return imgVals.concat(samples.dataMask)
}

0 comments on commit d826f50

Please sign in to comment.