Skip to content

Commit

Permalink
Update PlanetScope scripts (#308)
Browse files Browse the repository at this point in the history
* PlanetScope true color: use dataMask to make no-data pixels transparent

* PlanetScope false color: use dataMask to make no-data pixels transparent

* PlanetScope NDWI simple visualization: use dataMask to make no-data pixels transparent

* PlanetScope NDWI raw values: add script

* PlanetScope NDWI EOB visualization: add script

* PlanetScope NDWI: add scripts to readme.md

* add dataMask only at the end for PS NDWI script

* rename samples to sample in PS NDWI script

* remove unused dataMask band in PS NDWI raw script

* avoid returning infinite number in  PS NDWI raw script

* rename samples to sample in PS NDWIeob script

* add dataMask only at the end for PS NDWI eob script

* avoid returning infinite number in  PS NDWI eob script

* rename samples to sample in PS NDWIraw script

* improve eob script for PS NDWI

---------

Co-authored-by: Jonas <[email protected]>
  • Loading branch information
zcernigoj and jonasViehweger authored Jun 12, 2024
1 parent 9090f77 commit 524f538
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 17 deletions.
9 changes: 6 additions & 3 deletions planet_scope/ndwi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---


Expand Down
16 changes: 16 additions & 0 deletions planet_scope/ndwi/raw.js
Original file line number Diff line number Diff line change
@@ -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] };
}
39 changes: 26 additions & 13 deletions planet_scope/ndwi/script.js
Original file line number Diff line number Diff line change
@@ -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] };
}
2 changes: 1 addition & 1 deletion planet_scope/true_color/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ function setup() {

function evaluatePixel(sample) {
return [sample.red / 3000, sample.green / 3000, sample.blue / 3000, sample.dataMask];
}
}

0 comments on commit 524f538

Please sign in to comment.