Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Update PlanetScope scripts #308

wants to merge 6 commits into from

Conversation

zcernigoj
Copy link
Contributor

@zcernigoj zcernigoj commented Apr 10, 2024

Updated / added the NDWI scripts

  • cleaned up script.jswhich contains "normal" visualization without additional outputs needed for EO Browser statistics and histogram
  • added eob.js which contains additional outputs needed for EO Browser statistics and histogram
  • added raw.js which just outputs raw NDWI values

Updated true color and false color scripts

  • script.js for both now uses dataMask to make pixels with no data transparent

@zcernigoj zcernigoj changed the title update planetscope scripts Update PlanetScope scripts Apr 10, 2024
Copy link
Contributor

@chorng chorng left a 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,
Copy link
Contributor

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) {
Copy link
Contributor

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 };
Copy link
Contributor

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"] }],
Copy link
Contributor

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) {
Copy link
Contributor

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]};
Copy link
Contributor

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) {
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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;
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants