Skip to content

Commit

Permalink
Update SkySat scripts (#309)
Browse files Browse the repository at this point in the history
* PlanetScope NDVI: update script.js

* PlanetScope NDVI: add eob.js

* PlanetScope NDVI: add raw.js

* PlanetScope NDVI: add scripts to readme.md

* improve eob script for skysat

* improve raw script for skysat

* improve default script for skysat
  • Loading branch information
zcernigoj authored Jun 12, 2024
1 parent 524f538 commit c68d03e
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 13 deletions.
7 changes: 7 additions & 0 deletions skysat/ndvi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ grand_parent: Planet
layout: script
permalink: /skysat/ndvi/
nav_exclude: true
scripts:
- - Visualization
- script.js
- - EO Browser
- eob.js
- - Raw Values
- raw.js
---


Expand Down
38 changes: 38 additions & 0 deletions skysat/ndvi/eob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//VERSION=3
// NDVI

function setup() {
return {
input: ["Red", "NIR", "dataMask"],
output: [
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "FLOAT32" },
{ id: "eobrowserStats", bands: 2, sampleType: "FLOAT32" },
{ id: "dataMask", bands: 1 },
]
}
}

function evaluatePixel(sample) {
let NDVI = index(sample.NIR, sample.Red);
const indexVal = isFinite(NDVI) && sample.dataMask === 1 ? NDVI : NaN;
let id_default = valueInterpolate(NDVI,
[0, 0.2, 0.3, 0.4, 0.5, 1.0],
[
[1, 1, 0.88],
[0.57, 0.75, 0.32],
[0.44, 0.64, 0.25],
[0.31, 0.54, 0.18],
[0.19, 0.43, 0.11],
[0.06, 0.33, 0.04],
[0, 0.27, 0],
]
);

return {
default: [...id_default, sample.dataMask],
index: [indexVal],
eobrowserStats: [indexVal, sample.dataMask],
dataMask: [sample.dataMask],
};
}
16 changes: 16 additions & 0 deletions skysat/ndvi/raw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//VERSION=3
// NDVI

function setup() {
return {
input: ["Red", "NIR"],
output: [
{ id: "default", bands: 1 },
]
}
}

function evaluatePixel(sample) {
let NDVI = index(sample.NIR, sample.Red);
return { default: [NDVI] };
}
34 changes: 21 additions & 13 deletions skysat/ndvi/script.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
//VERSION=3
// NDVI

function setup() {
return {
input: ["red", "nir", "dataMask"],
output: { bands: 4 }
input: ["Red", "NIR", "dataMask"],
output: [
{ id: "default", bands: 4 },
]
}
}
var f = 10000

function evaluatePixel(sample) {
var NDVI = index(sample.nir, sample.red)
return valueInterpolate(NDVI,
let NDVI = index(sample.NIR, sample.Red);
let id_default = valueInterpolate(NDVI,
[0, 0.2, 0.3, 0.4, 0.5, 1.0],
[
[1, 1, 0.88, sample.dataMask],
[0.57, 0.75, 0.32, sample.dataMask],
[0.44, 0.64, 0.25, sample.dataMask],
[0.31, 0.54, 0.18, sample.dataMask],
[0.19, 0.43, 0.11, sample.dataMask],
[0.06, 0.33, 0.04, sample.dataMask],
[0, 0.27, 0, sample.dataMask],
])
[1, 1, 0.88],
[0.57, 0.75, 0.32],
[0.44, 0.64, 0.25],
[0.31, 0.54, 0.18],
[0.19, 0.43, 0.11],
[0.06, 0.33, 0.04],
[0, 0.27, 0],
]);

return {
default: [...id_default, sample.dataMask],
};
}

0 comments on commit c68d03e

Please sign in to comment.