diff --git a/planet_scope/ndwi/README.md b/planet_scope/ndwi/README.md index a2f65ff8..6a89e1c1 100644 --- a/planet_scope/ndwi/README.md +++ b/planet_scope/ndwi/README.md @@ -6,9 +6,12 @@ layout: script permalink: /planet_scope/ndwi/ nav_exclude: true scripts: -scripts: - - [Visualization, script.js] - - [EO Browser, eob.js] +- - Visualization + - script.js +- - EO Browser + - eob.js +- - Raw Values + - raw.js --- diff --git a/planet_scope/ndwi/raw.js b/planet_scope/ndwi/raw.js new file mode 100644 index 00000000..7955731c --- /dev/null +++ b/planet_scope/ndwi/raw.js @@ -0,0 +1,16 @@ +//VERSION=3 +//NDWI + +function setup() { + return { + input: [{ bands: ["green", "nir"] }], + output: [ + { id: "default", bands: 1, sampleType: "FLOAT32" }, + ] + } +} + +function evaluatePixel(sample) { + let ndwi = index(sample.green, sample.nir); + return { default: [isFinite(ndwi) ? ndwi : NaN] }; +} \ No newline at end of file diff --git a/planet_scope/ndwi/script.js b/planet_scope/ndwi/script.js index 05c6a90f..3e56a725 100644 --- a/planet_scope/ndwi/script.js +++ b/planet_scope/ndwi/script.js @@ -1,17 +1,30 @@ +//VERSION=3 //NDWI -let ndwi = index(green, nir); +function setup() { + return { + input: [{ bands: ["green", "nir", "dataMask"] }], + output: [ + { id: "default", bands: 4 }, + ] + } +} -return colorBlend(ndwi, - [-1, -0.5, -0.2, 0, 0.2, 0.5, 1.0], - [ - [1, 0, 1], - [1, 0.5, 0], - [1, 1, 0], - [0.2, 1, 0.5], - [0, 0, 1], - [0, 0, 0.3], - [0, 0, 0], - ] -); +function evaluatePixel(sample) { + let ndwi = index(green, nir); + let id_default = colorBlend(ndwi, + [-1, -0.5, -0.2, 0, 0.2, 0.5, 1.0], + [ + [1, 0, 1], + [1, 0.5, 0], + [1, 1, 0], + [0.2, 1, 0.5], + [0, 0, 1], + [0, 0, 0.3], + [0, 0, 0], + ] + ); + + return { default: [...id_default, sample.dataMask] }; +} diff --git a/planet_scope/true_color/script.js b/planet_scope/true_color/script.js index 8b451d33..ae79f7f2 100644 --- a/planet_scope/true_color/script.js +++ b/planet_scope/true_color/script.js @@ -10,4 +10,4 @@ function setup() { function evaluatePixel(sample) { return [sample.red / 3000, sample.green / 3000, sample.blue / 3000, sample.dataMask]; -} \ No newline at end of file +}