-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update PlanetScope scripts #308
base: main
Are you sure you want to change the base?
Conversation
…ixels transparent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some comments for minor changes.
function evaluatePixel(samples) { | ||
let ndwi = (samples.green / 3000 - samples.nir / 3000) / (samples.green / 3000 + samples.nir / 3000); | ||
|
||
let id_default = colorBlend(ndwi, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest removing dataMask from the colorBlend function to avoid repeatation. For example:
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],
]
);
} | ||
} | ||
|
||
function evaluatePixel(samples) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For SIMPLE
mosaicking I would use sample
] | ||
); | ||
|
||
return { default: id_default }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To include dataMask we can return
return { default: id_default.concat(sample.dataMask) };
|
||
function setup() { | ||
return { | ||
input: [{ bands: ["green", "nir", "dataMask"] }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the dataMask as it is not used in the evaluatePixel function
} | ||
} | ||
|
||
function evaluatePixel(samples) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For SIMPLE
mosaicking I would suggest using sample
|
||
function evaluatePixel(samples) { | ||
let ndwi = index(samples.green, samples.nir); | ||
return {default: [ndwi]}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid infinite value I would suggest returning the following:
return {default: [isFinite(ndwi) ? ndwi : NaN]};
} | ||
} | ||
|
||
function evaluatePixel(samples) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For SIMPLE
mosaicking I would use sample
let ndwi = (samples.Green / 3000 - samples.NIR / 3000) / (samples.Green / 3000 + samples.NIR / 3000); | ||
const indexVal = samples.dataMask === 1 ? ndwi : NaN; | ||
|
||
let id_default = colorBlend(ndwi, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the visualisation script. I would remove the dataMask from the colorBlend function to avoid repeatation
); | ||
|
||
return { | ||
default: id_default, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include dataMask by returning
id_default.concat(sample.dataMask)
|
||
function evaluatePixel(samples) { | ||
let ndwi = (samples.Green / 3000 - samples.NIR / 3000) / (samples.Green / 3000 + samples.NIR / 3000); | ||
const indexVal = samples.dataMask === 1 ? ndwi : NaN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would mask infinite number ((sample.Green + sample.NIR) == 0
) as well.
Updated / added the NDWI scripts
script.js
which contains "normal" visualization without additional outputs needed for EO Browser statistics and histogrameob.js
which contains additional outputs needed for EO Browser statistics and histogramraw.js
which just outputs raw NDWI valuesUpdated
true color
andfalse color
scriptsscript.js
for both now usesdataMask
to make pixels with no data transparent