Skip to content

Commit 0254fc5

Browse files
jonasViehwegerJonas Viehweger
and
Jonas Viehweger
authored
Added separate scripts for Mapzen and COP-DEM (#336)
Co-authored-by: Jonas Viehweger <[email protected]>
1 parent 5f05c28 commit 0254fc5

File tree

5 files changed

+140
-135
lines changed

5 files changed

+140
-135
lines changed

dem/dem-topographic/cop-dem.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//VERSION=3
2+
// To set custom max and min values, set
3+
// choose your max and min values.
4+
// The color map will then be scaled
5+
// to those max and min values
6+
const max = 8000;
7+
const min = 0;
8+
9+
function setup() {
10+
return {
11+
input: ["DEM", "dataMask"],
12+
output: [
13+
{ id: "default", bands: 4, sampleType: "AUTO" },
14+
{ id: "index", bands: 1, sampleType: "FLOAT32" },
15+
{ id: "dataMask", bands: 1 },
16+
],
17+
};
18+
}
19+
const map = [
20+
[8000, 0xffffff],
21+
[7000, 0xf2f2f2],
22+
[6000, 0xe5e5e5],
23+
[5500, 0x493811],
24+
[5000, 0x5e4c26],
25+
[4500, 0x726038],
26+
[4000, 0x87724c],
27+
[3500, 0x998760],
28+
[3000, 0xad9b75],
29+
[2500, 0xc1af89],
30+
[2000, 0xd6c49e],
31+
[1500, 0xead8af],
32+
[1000, 0xfcedbf],
33+
[900, 0xaadda0],
34+
[800, 0xa5d69b],
35+
[700, 0x96ce8e],
36+
[600, 0x84c17a],
37+
[500, 0x7aba70],
38+
[400, 0x72b266],
39+
[300, 0x5ea354],
40+
[200, 0x4c933f],
41+
[100, 0x3d873d],
42+
[75, 0x357c3a],
43+
[50, 0x2d722d],
44+
[25, 0x266821],
45+
[10, 0x1e5e14],
46+
[0.00001, 0x165407],
47+
[0, 0x0f0f8c],
48+
];
49+
50+
const visualizer = new ColorRampVisualizer(map, min, max);
51+
52+
function evaluatePixel(samples) {
53+
const imgVals = visualizer.process(samples.DEM);
54+
55+
// Return the 4 inputs and define content for each one
56+
return {
57+
default: [...imgVals, samples.dataMask],
58+
index: [samples.DEM],
59+
dataMask: [samples.dataMask],
60+
};
61+
}

dem/dem-topographic/eob.js

-84
This file was deleted.

dem/dem-topographic/README.md dem/dem-topographic/index.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
title: DEM Topographic Visualization
33
parent: DEM
44
layout: script
5-
permalink: /dem/dem-topographic/
65
nav_exclude: true
76
scripts:
8-
- - Visualization
9-
- script.js
10-
- - EO Browser
11-
- eob.js
7+
- - Mapzen
8+
- mapzen.js
9+
- - COP-DEM
10+
- cop-dem.js
1211
examples:
1312
- zoom: '10'
1413
lat: '42.40876'
@@ -19,7 +18,7 @@ examples:
1918
platform:
2019
- CDSE
2120
- EOB
22-
evalscripturl: https://custom-scripts.sentinel-hub.com/dem/dem-topographic/eob.js
21+
evalscripturl: https://custom-scripts.sentinel-hub.com/dem/dem-topographic/mapzen.js
2322
---
2423

2524

dem/dem-topographic/mapzen.js

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//VERSION=3
2+
// To set custom max and min values, set
3+
// defaultVis to false and choose your max and
4+
// min values. The color map will then be scaled
5+
// to those max and min values
6+
7+
const max = 8000;
8+
const min = -5000;
9+
const seaLevel = 0;
10+
11+
function setup() {
12+
return {
13+
input: ["DEM", "dataMask"],
14+
output: [
15+
{ id: "default", bands: 4, sampleTYPE: "AUTO" },
16+
{ id: "index", bands: 1, sampleType: "FLOAT32" },
17+
{ id: "dataMask", bands: 1 },
18+
],
19+
};
20+
}
21+
22+
const landMap = [
23+
[8000, 0xffffff],
24+
[7000, 0xf2f2f2],
25+
[6000, 0xe5e5e5],
26+
[5500, 0x493811],
27+
[5000, 0x5e4c26],
28+
[4500, 0x726038],
29+
[4000, 0x87724c],
30+
[3500, 0x998760],
31+
[3000, 0xad9b75],
32+
[2500, 0xc1af89],
33+
[2000, 0xd6c49e],
34+
[1500, 0xead8af],
35+
[1000, 0xfcedbf],
36+
[900, 0xaadda0],
37+
[800, 0xa5d69b],
38+
[700, 0x96ce8e],
39+
[600, 0x84c17a],
40+
[500, 0x7aba70],
41+
[400, 0x72b266],
42+
[300, 0x5ea354],
43+
[200, 0x4c933f],
44+
[100, 0x3d873d],
45+
[75, 0x357c3a],
46+
[50, 0x2d722d],
47+
[25, 0x266821],
48+
[10, 0x1e5e14],
49+
[0, 0x165407],
50+
];
51+
52+
// add ocean color
53+
const waterMap = [
54+
[-5, 0xa8d1ea],
55+
[-50, 0x89a8d1],
56+
[-100, 0x687fba],
57+
[-500, 0x4759a0],
58+
[-1000, 0x283087],
59+
[-5000, 0x070772],
60+
];
61+
const landVis = new ColorRampVisualizer(landMap, waterLevel, max);
62+
const waterVis = new ColorRampVisualizer(waterMap, min, waterLevel);
63+
64+
function evaluatePixel(sample) {
65+
let val = sample.DEM;
66+
let imgVals = val > waterLevel ? landVis.process(val) : waterVis.process(val);
67+
68+
// Return the 4 inputs and define content for each one
69+
return {
70+
default: [...imgVals, sample.dataMask],
71+
index: [val],
72+
dataMask: [sample.dataMask],
73+
};
74+
}

dem/dem-topographic/script.js

-45
This file was deleted.

0 commit comments

Comments
 (0)