Skip to content

Commit

Permalink
Merge pull request #293 from sentinel-hub/feat/pvs-multi-script
Browse files Browse the repository at this point in the history
Added multi script support to remaining pvs
  • Loading branch information
jonasViehweger authored Dec 19, 2023
2 parents 07facda + c73bb0b commit a18e555
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 120 deletions.
62 changes: 32 additions & 30 deletions planetary-variables/crop-biomass/crop-biomass-visualization/eob.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
//VERSION=3
// To set custom max and min values, set
// defaultVis to false and choose your max and
// min values. The color map will then be scaled
// to those max and min values
function setup() {
return {
input: ["CB", "dataMask"],
output: [
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: 'FLOAT32' },
{ id: "eobrowserStats", bands: 1, sampleType: 'FLOAT32' },
{ id: "dataMask", bands: 1 }
]
};
return {
input: ["CB", "dataMask"],
output: [
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "FLOAT32" },
{ id: "eobrowserStats", bands: 1, sampleType: "FLOAT32" },
{ id: "dataMask", bands: 1 },
],
};
}


const bp_ramp = [
[0, 0xfff7ea],
[0.100, 0xf3e3c8],
[0.200, 0xdad0a4],
[0.300, 0xbdc082],
[0.400, 0x99b160],
[0.500, 0x6da242],
[0.600, 0x2c952e],
[0.7000, 0x008729],
[0.800, 0x007932],
[0.9000, 0x006640],
[1.000, 0x005444],
[0, 0xfff7ea],
[0.1, 0xf3e3c8],
[0.2, 0xdad0a4],
[0.3, 0xbdc082],
[0.4, 0x99b160],
[0.5, 0x6da242],
[0.6, 0x2c952e],
[0.7, 0x008729],
[0.8, 0x007932],
[0.9, 0x006640],
[1.0, 0x005444],
];

const visualizer = new ColorRampVisualizer(bp_ramp);

let factor = 1 / 1000;
function evaluatePixel(sample) {
let val = sample.CB * factor;
let imgVals = visualizer.process(val);
return {
default: [...imgVals, sample.dataMask],
index: [val],
eobrowserStats: [val],
dataMask: [sample.dataMask]
};
let val = sample.CB * factor;
let imgVals = visualizer.process(val);
return {
default: [...imgVals, sample.dataMask],
index: [val],
eobrowserStats: [val],
dataMask: [sample.dataMask],
};
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//VERSION=3
const defaultVis = true
const max = 175
const min = 0
// To set custom max and min values, set
// defaultVis to false and choose your max and
// min values. The color map will then be scaled
// to those max and min values
const defaultVis = true;
const max = 175;
const min = 0;

function setup() {
return {
Expand All @@ -10,32 +14,32 @@ function setup() {
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "INT16" },
{ id: "eobrowserStats", bands: 1, sampleType: "FLOAT32" },
{ id: "dataMask", bands: 1 }
]
{ id: "dataMask", bands: 1 },
],
};
}

function updateMap(max, min) {
const numIntervals = map.length
const numIntervals = map.length;
const intervalLength = (max - min) / (numIntervals - 1);
for (let i = 0; i < numIntervals; i++) {
map[i][0] = max - intervalLength * i
map[i][0] = max - intervalLength * i;
}
}

const map = [
[175, 0xE5DD26],
[155, 0xCED62F],
[140, 0x9EC54A],
[125, 0x63B16E],
[110, 0x38A183],
[95, 0x1B8583],
[80, 0x1E8589],
[175, 0xe5dd26],
[155, 0xced62f],
[140, 0x9ec54a],
[125, 0x63b16e],
[110, 0x38a183],
[95, 0x1b8583],
[80, 0x1e8589],
[65, 0x206378],
[50, 0x2E4C67],
[35, 0x2A3F62],
[20, 0x2D1A4E],
[5, 0x2E164C],
[50, 0x2e4c67],
[35, 0x2a3f62],
[20, 0x2d1a4e],
[5, 0x2e164c],
[0, 0x360245],
];

Expand All @@ -44,12 +48,12 @@ const visualizer = new ColorRampVisualizer(map);

function evaluatePixel(sample) {
let val = sample.ACD;
let imgVals = visualizer.process(val)
let imgVals = visualizer.process(val);

return {
default: imgVals.concat(sample.dataMask),
index: [val],
eobrowserStats: [val],
dataMask: [sample.dataMask]
dataMask: [sample.dataMask],
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ function setup() {
}

function evaluatePixel(sample) {
return [sample.ACD]
return [sample.ACD];
}
40 changes: 22 additions & 18 deletions planetary-variables/forest-carbon-diligence/canopy-cover/eob.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//VERSION=3
const defaultVis = true
const max = 100
const min = 0
// To set custom max and min values, set
// defaultVis to false and choose your max and
// min values. The color map will then be scaled
// to those max and min values
const defaultVis = true;
const max = 100;
const min = 0;

function setup() {
return {
Expand All @@ -10,44 +14,44 @@ function setup() {
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "UINT8" },
{ id: "eobrowserStats", bands: 1, sampleType: "FLOAT32" },
{ id: "dataMask", bands: 1 }
]
{ id: "dataMask", bands: 1 },
],
};
}

function updateMap(max, min) {
const numIntervals = map.length
const numIntervals = map.length;
const intervalLength = (max - min) / (numIntervals - 1);
for (let i = 0; i < numIntervals; i++) {
map[i][0] = max - intervalLength * i
map[i][0] = max - intervalLength * i;
}
}

const map = [
[100, 0x183D19],
[90, 0x124F24],
[80, 0x0E6327],
[70, 0x246D29],
[100, 0x183d19],
[90, 0x124f24],
[80, 0x0e6327],
[70, 0x246d29],
[60, 0x498418],
[50, 0x669516],
[40, 0x859E25],
[30, 0xA4AB38],
[20, 0xD3C058],
[10, 0xDDD17C],
[0, 0xF0F5D5],
[40, 0x859e25],
[30, 0xa4ab38],
[20, 0xd3c058],
[10, 0xddd17c],
[0, 0xf0f5d5],
];

if (!defaultVis) updateMap(max, min);
const visualizer = new ColorRampVisualizer(map);

function evaluatePixel(sample) {
let val = sample.CC;
let imgVals = visualizer.process(val)
let imgVals = visualizer.process(val);

return {
default: imgVals.concat(sample.dataMask),
index: [val],
eobrowserStats: [val],
dataMask: [sample.dataMask]
dataMask: [sample.dataMask],
};
}
30 changes: 17 additions & 13 deletions planetary-variables/forest-carbon-diligence/canopy-height/eob.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//VERSION=3
const defaultVis = true
const max = 30
const min = 0
// To set custom max and min values, set
// defaultVis to false and choose your max and
// min values. The color map will then be scaled
// to those max and min values
const defaultVis = true;
const max = 30;
const min = 0;

function setup() {
return {
Expand All @@ -10,37 +14,37 @@ function setup() {
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "UINT8" },
{ id: "eobrowserStats", bands: 1, sampleType: "FLOAT32" },
{ id: "dataMask", bands: 1 }
]
{ id: "dataMask", bands: 1 },
],
};
}

function updateMap(max, min) {
const numIntervals = map.length
const numIntervals = map.length;
const intervalLength = (max - min) / (numIntervals - 1);
for (let i = 0; i < numIntervals; i++) {
map[i][0] = max - intervalLength * i
map[i][0] = max - intervalLength * i;
}
}

const map = [
[30, 0x345E03],
[20, 0x6DA20C],
[10, 0xBACE6E],
[0, 0xF0F5D5],
[30, 0x345e03],
[20, 0x6da20c],
[10, 0xbace6e],
[0, 0xf0f5d5],
];

if (!defaultVis) updateMap(max, min);
const visualizer = new ColorRampVisualizer(map);

function evaluatePixel(sample) {
let val = sample.CH;
let imgVals = visualizer.process(val)
let imgVals = visualizer.process(val);

return {
default: imgVals.concat(sample.dataMask),
index: [val],
eobrowserStats: [val],
dataMask: [sample.dataMask]
dataMask: [sample.dataMask],
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ grand_parent: Planetary Variables
parent: Land Surface Temperature
layout: script
nav_exclude: false
scripts:
- [Visualization, script.js]
- [EO Browser, eob.js]
- [Raw Values, raw.js]
---

## Evaluate and visualize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ const variable = "LST" // LST or LST_MaskedPixels
function setup() {
return {
input: [variable, "dataMask"],
output: [{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: 'FLOAT32' },
{ id: "eobrowserStats", bands: 1, sampleType: 'FLOAT32' },
{ id: "dataMask", bands: 1 }],
output: { bands: 4 },
mosaicking: "TILE"
};
}
Expand Down Expand Up @@ -91,10 +88,5 @@ function evaluatePixel(samples) {

// Display
let imgVals = visualizer.process(indexVal);
return {
default: [...imgVals, datamask],
index: [array],
eobrowserStats: [indexVal, datamask],
dataMask: [datamask]
};
return [...imgVals, datamask];
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ grand_parent: Planetary Variables
parent: Soil Water Content
layout: script
nav_exclude: false
scripts:
- [Visualization, script.js]
- [EO Browser, eob.js]
- [Raw Values, raw.js]
---

## Evaluate and visualize
Expand Down
Loading

0 comments on commit a18e555

Please sign in to comment.