Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willrayeo/d82188a2c21efacef90919f27cc1307b to your computer and use it in GitHub Desktop.
Save willrayeo/d82188a2c21efacef90919f27cc1307b to your computer and use it in GitHub Desktop.
//VERSION=3
// Script to extract a time series of Band 5 values using
// Sentinel 2 Level 2A data and metadata file.
function setup() {
return {
input: [{
bands: ["B05"],
units: "DN"
}],
output: {
id: "S2_L2A",
bands: 1,
sampleType: SampleType.UINT16
},
mosaicking: Mosaicking.ORBIT
}
}
// The following function is designed to update the number of
// output bands without knowing beforehand how many there are
function updateOutput(outputs, collection) {
Object.values(outputs).forEach((output) => {
output.bands = collection.scenes.length;
});
}
function evaluatePixel(samples) {
// Precompute an array to contain B05 observations
var n_observations = samples.length;
let band_05 = new Array(n_observations).fill(0);
// Fill the array
samples.forEach((sample, index) => {
band_05[index] = sample.B05;
});
return band_05;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment