Created
May 31, 2023 15:09
-
-
Save willrayeo/d82188a2c21efacef90919f27cc1307b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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