Skip to content

Commit

Permalink
Added separate scripts for Mapzen and COP-DEM (#336)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas Viehweger <[email protected]>
  • Loading branch information
jonasViehweger and Jonas Viehweger authored Nov 12, 2024
1 parent 5f05c28 commit 0254fc5
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 135 deletions.
61 changes: 61 additions & 0 deletions dem/dem-topographic/cop-dem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//VERSION=3
// To set custom max and min values, set
// choose your max and min values.
// The color map will then be scaled
// to those max and min values
const max = 8000;
const min = 0;

function setup() {
return {
input: ["DEM", "dataMask"],
output: [
{ id: "default", bands: 4, sampleType: "AUTO" },
{ id: "index", bands: 1, sampleType: "FLOAT32" },
{ id: "dataMask", bands: 1 },
],
};
}
const map = [
[8000, 0xffffff],
[7000, 0xf2f2f2],
[6000, 0xe5e5e5],
[5500, 0x493811],
[5000, 0x5e4c26],
[4500, 0x726038],
[4000, 0x87724c],
[3500, 0x998760],
[3000, 0xad9b75],
[2500, 0xc1af89],
[2000, 0xd6c49e],
[1500, 0xead8af],
[1000, 0xfcedbf],
[900, 0xaadda0],
[800, 0xa5d69b],
[700, 0x96ce8e],
[600, 0x84c17a],
[500, 0x7aba70],
[400, 0x72b266],
[300, 0x5ea354],
[200, 0x4c933f],
[100, 0x3d873d],
[75, 0x357c3a],
[50, 0x2d722d],
[25, 0x266821],
[10, 0x1e5e14],
[0.00001, 0x165407],
[0, 0x0f0f8c],
];

const visualizer = new ColorRampVisualizer(map, min, max);

function evaluatePixel(samples) {
const imgVals = visualizer.process(samples.DEM);

// Return the 4 inputs and define content for each one
return {
default: [...imgVals, samples.dataMask],
index: [samples.DEM],
dataMask: [samples.dataMask],
};
}
84 changes: 0 additions & 84 deletions dem/dem-topographic/eob.js

This file was deleted.

11 changes: 5 additions & 6 deletions dem/dem-topographic/README.md → dem/dem-topographic/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
title: DEM Topographic Visualization
parent: DEM
layout: script
permalink: /dem/dem-topographic/
nav_exclude: true
scripts:
- - Visualization
- script.js
- - EO Browser
- eob.js
- - Mapzen
- mapzen.js
- - COP-DEM
- cop-dem.js
examples:
- zoom: '10'
lat: '42.40876'
Expand All @@ -19,7 +18,7 @@ examples:
platform:
- CDSE
- EOB
evalscripturl: https://custom-scripts.sentinel-hub.com/dem/dem-topographic/eob.js
evalscripturl: https://custom-scripts.sentinel-hub.com/dem/dem-topographic/mapzen.js
---


Expand Down
74 changes: 74 additions & 0 deletions dem/dem-topographic/mapzen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//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

const max = 8000;
const min = -5000;
const seaLevel = 0;

function setup() {
return {
input: ["DEM", "dataMask"],
output: [
{ id: "default", bands: 4, sampleTYPE: "AUTO" },
{ id: "index", bands: 1, sampleType: "FLOAT32" },
{ id: "dataMask", bands: 1 },
],
};
}

const landMap = [
[8000, 0xffffff],
[7000, 0xf2f2f2],
[6000, 0xe5e5e5],
[5500, 0x493811],
[5000, 0x5e4c26],
[4500, 0x726038],
[4000, 0x87724c],
[3500, 0x998760],
[3000, 0xad9b75],
[2500, 0xc1af89],
[2000, 0xd6c49e],
[1500, 0xead8af],
[1000, 0xfcedbf],
[900, 0xaadda0],
[800, 0xa5d69b],
[700, 0x96ce8e],
[600, 0x84c17a],
[500, 0x7aba70],
[400, 0x72b266],
[300, 0x5ea354],
[200, 0x4c933f],
[100, 0x3d873d],
[75, 0x357c3a],
[50, 0x2d722d],
[25, 0x266821],
[10, 0x1e5e14],
[0, 0x165407],
];

// add ocean color
const waterMap = [
[-5, 0xa8d1ea],
[-50, 0x89a8d1],
[-100, 0x687fba],
[-500, 0x4759a0],
[-1000, 0x283087],
[-5000, 0x070772],
];
const landVis = new ColorRampVisualizer(landMap, waterLevel, max);
const waterVis = new ColorRampVisualizer(waterMap, min, waterLevel);

function evaluatePixel(sample) {
let val = sample.DEM;
let imgVals = val > waterLevel ? landVis.process(val) : waterVis.process(val);

// Return the 4 inputs and define content for each one
return {
default: [...imgVals, sample.dataMask],
index: [val],
dataMask: [sample.dataMask],
};
}
45 changes: 0 additions & 45 deletions dem/dem-topographic/script.js

This file was deleted.

0 comments on commit 0254fc5

Please sign in to comment.