-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #285 from sentinel-hub/feat/multiscript
Added multiple scripts and example links to Copernicus Browser
- Loading branch information
Showing
48 changed files
with
1,019 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//VERSION=3 | ||
function setup() { | ||
return { | ||
input: ["VV", "VH", "dataMask"], | ||
output: [ | ||
{ id: "default", bands: 4 }, | ||
{ id: "index", bands: 1, sampleType: "FLOAT32" }, | ||
{ id: "eobrowserStats", bands: 1, sampleType: 'FLOAT32' }, | ||
{ id: "dataMask", bands: 1 } | ||
] | ||
}; | ||
} | ||
|
||
const ramp = [ | ||
[0, 0x8e0152], | ||
[0.25, 0xde77ae], | ||
[0.5, 0xf7f7f7], | ||
[0.75, 0x7fbc41], | ||
[1, 0x276419], | ||
]; | ||
|
||
|
||
const visualizer = new ColorRampVisualizer(ramp); | ||
|
||
function evaluatePixel(samples) { | ||
let dop = (samples.VV / (samples.VV + samples.VH)); | ||
let m = 1 - dop; | ||
//depolarization within the vegetation | ||
let val = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH)); | ||
// 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], | ||
eobrowserStats: [val], | ||
dataMask: [samples.dataMask] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Radar vegetation index for Sentinel-1 (RVI4S1) SAR data | ||
// Institute: MRSLab, Indian Institute of Technology Bombay, India | ||
// Data requirements: Sentinel-1 GRD data | ||
function setup() { | ||
return { | ||
input: ["VV", "VH"], | ||
output: { bands: 1, sampleType: "FLOAT32" } | ||
}; | ||
} | ||
|
||
function evaluatePixel(samples) { | ||
//equivalent to complement of the degree of polarization | ||
let dop = (samples.VV / (samples.VV + samples.VH)); | ||
let m = 1 - dop; | ||
//depolarization within the vegetation | ||
let value = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH)); | ||
return [value] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
// Radar vegetation index for Sentinel-1 (RVI4S1) SAR data | ||
// Institute: MRSLab, Indian Institute of Technology Bombay, India | ||
// Data requirements: Sentinel-1 GRD data | ||
let dop = (VV/(VV+VH)); //equivalent to complement of the degree of polarization | ||
let m = 1 - dop; | ||
let value = (Math.sqrt(dop))*((4*(VH))/(VV+VH)); //depolarization within the vegetation | ||
|
||
//return [ value ] //Grayscale result | ||
|
||
// Colour scale | ||
return colorBlend // call the colorBlend function | ||
(value, // Pixel value | ||
[0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0], // Define the borders | ||
[ [0, 0, 1], // Define the RGB colors for each border | ||
[0.1,0.2,0.8], | ||
[0.3, 0.5, 0.7], | ||
[0.2, 1, 0.3], | ||
[0.5, 0.8, 0.2], | ||
[1, 0.4, 0], | ||
[1, 0, 0], | ||
]); | ||
// Radar vegetation index for Sentinel-1 (RVI4S1) SAR data | ||
// Institute: MRSLab, Indian Institute of Technology Bombay, India | ||
// Data requirements: Sentinel-1 GRD data | ||
function setup() { | ||
return { | ||
input: ["VV", "VH", "dataMask"], | ||
output: { bands: 4 } | ||
}; | ||
} | ||
|
||
const ramp = [ | ||
[0, 0x8e0152], | ||
[0.25, 0xde77ae], | ||
[0.5, 0xf7f7f7], | ||
[0.75, 0x7fbc41], | ||
[1, 0x276419], | ||
]; | ||
|
||
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; | ||
//depolarization within the vegetation | ||
let value = (Math.sqrt(dop)) * ((4 * (samples.VH)) / (samples.VV + samples.VH)); | ||
let imgVals = visualizer.process(value); | ||
return imgVals.concat(samples.dataMask) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//VERSION=3 | ||
function setup() { | ||
return { | ||
input: ["B02", "B03", "B04", "B08", "dataMask"], | ||
output: [ | ||
{ id: "default", bands: 4 }, | ||
{ id: "index", bands: 1, sampleType: "FLOAT32" }, | ||
{ id: "eobrowserStats", bands: 2, sampleType: 'FLOAT32' }, | ||
{ id: "dataMask", bands: 1 } | ||
] | ||
}; | ||
} | ||
|
||
const ramp = [ | ||
[-0.5, 0x0c0c0c], | ||
[-0.2, 0xbfbfbf], | ||
[-0.1, 0xdbdbdb], | ||
[0, 0xeaeaea], | ||
[0.025, 0xfff9cc], | ||
[0.05, 0xede8b5], | ||
[0.075, 0xddd89b], | ||
[0.1, 0xccc682], | ||
[0.125, 0xbcb76b], | ||
[0.15, 0xafc160], | ||
[0.175, 0xa3cc59], | ||
[0.2, 0x91bf51], | ||
[0.25, 0x7fb247], | ||
[0.3, 0x70a33f], | ||
[0.35, 0x609635], | ||
[0.4, 0x4f892d], | ||
[0.45, 0x3f7c23], | ||
[0.5, 0x306d1c], | ||
[0.55, 0x216011], | ||
[0.6, 0x0f540a], | ||
[1, 0x004400], | ||
]; | ||
|
||
const visualizer = new ColorRampVisualizer(ramp); | ||
|
||
function evaluatePixel(samples) { | ||
let val = 2.5 * (samples.B08 - samples.B04) / ((samples.B08 + 6.0 * samples.B04 - 7.5 * samples.B02) + 1.0); | ||
// 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], | ||
eobrowserStats: [val, isCloud(samples) ? 1 : 0], | ||
dataMask: [samples.dataMask] | ||
}; | ||
} | ||
|
||
function isCloud(samples) { | ||
const NGDR = index(samples.B03, samples.B04); | ||
const bRatio = (samples.B03 - 0.175) / (0.39 - 0.175); | ||
return bRatio > 1 || (bRatio > 0 && NGDR > 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//VERSION=3 | ||
function setup() { | ||
return { | ||
input: ["B02", "B04", "B08"], | ||
output: { | ||
bands: 1, | ||
sampleType: "FLOAT32" | ||
} | ||
}; | ||
} | ||
|
||
function evaluatePixel(samples) { | ||
return [2.5 * (samples.B08 - samples.B04) / ((samples.B08 + 6.0 * samples.B04 - 7.5 * samples.B02) + 1.0)] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
//VERSION=3 | ||
// Enhanced Vegetation Index (abbrv. EVI) | ||
// General formula: 2.5 * (NIR - RED) / ((NIR + 6*RED - 7.5*BLUE) + 1) | ||
// URL https://www.indexdatabase.de/db/si-single.php?sensor_id=96&rsindex_id=16 | ||
function setup() { | ||
return { | ||
input: ["B02", "B04", "B08", "dataMask"], | ||
output: { bands: 4 } | ||
}; | ||
} | ||
|
||
let EVI = 2.5 * (B08 - B04) / ((B08 + 6.0 * B04 - 7.5 * B02) + 1.0); | ||
const ramp = [ | ||
[-0.5, 0x0c0c0c], | ||
[-0.2, 0xbfbfbf], | ||
[-0.1, 0xdbdbdb], | ||
[0, 0xeaeaea], | ||
[0.025, 0xfff9cc], | ||
[0.05, 0xede8b5], | ||
[0.075, 0xddd89b], | ||
[0.1, 0xccc682], | ||
[0.125, 0xbcb76b], | ||
[0.15, 0xafc160], | ||
[0.175, 0xa3cc59], | ||
[0.2, 0x91bf51], | ||
[0.25, 0x7fb247], | ||
[0.3, 0x70a33f], | ||
[0.35, 0x609635], | ||
[0.4, 0x4f892d], | ||
[0.45, 0x3f7c23], | ||
[0.5, 0x306d1c], | ||
[0.55, 0x216011], | ||
[0.6, 0x0f540a], | ||
[1, 0x004400], | ||
]; | ||
|
||
if (EVI<-1.1) return [0,0,0]; | ||
else if (EVI<-0.2) return [0.75,0.75,0.75]; | ||
else if (EVI<-0.1) return [0.86,0.86,0.86]; | ||
else if (EVI<0) return [1,1,0.88]; | ||
else if (EVI<0.025) return [1,0.98,0.8]; | ||
else if (EVI<0.05) return [0.93,0.91,0.71]; | ||
else if (EVI<0.075) return [0.87,0.85,0.61]; | ||
else if (EVI<0.1) return [0.8,0.78,0.51]; | ||
else if (EVI<0.125) return [0.74,0.72,0.42]; | ||
else if (EVI<0.15) return [0.69,0.76,0.38]; | ||
else if (EVI<0.175) return [0.64,0.8,0.35]; | ||
else if (EVI<0.2) return [0.57,0.75,0.32]; | ||
else if (EVI<0.25) return [0.5,0.7,0.28]; | ||
else if (EVI<0.3) return [0.44,0.64,0.25]; | ||
else if (EVI<0.35) return [0.38,0.59,0.21]; | ||
else if (EVI<0.4) return [0.31,0.54,0.18]; | ||
else if (EVI<0.45) return [0.25,0.49,0.14]; | ||
else if (EVI<0.5) return [0.19,0.43,0.11]; | ||
else if (EVI<0.55) return [0.13,0.38,0.07]; | ||
else if (EVI<0.6) return [0.06,0.33,0.04]; | ||
else return [0,0.27,0]; | ||
const visualizer = new ColorRampVisualizer(ramp); | ||
|
||
function evaluatePixel(samples) { | ||
let evi = 2.5 * (samples.B08 - samples.B04) / ((samples.B08 + 6.0 * samples.B04 - 7.5 * samples.B02) + 1.0); | ||
let imgVals = visualizer.process(evi); | ||
return imgVals.concat(samples.dataMask) | ||
} |
Oops, something went wrong.