From 372168e253438749b05f0b124f1f6f6ac8435bcf Mon Sep 17 00:00:00 2001 From: wray Date: Tue, 25 Jun 2024 12:17:00 +0200 Subject: [PATCH] raw script added --- planet_scope/max_ndvi/raw.js | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 planet_scope/max_ndvi/raw.js diff --git a/planet_scope/max_ndvi/raw.js b/planet_scope/max_ndvi/raw.js new file mode 100644 index 00000000..86cfb704 --- /dev/null +++ b/planet_scope/max_ndvi/raw.js @@ -0,0 +1,48 @@ +//VERSION=3 + +//Basic initialization setup function +function setup() { + return { + //List of all bands, that will be used in the script, either for visualization or for choosing best pixel + input: [{ + bands: [ + "Red", + "NIR" + ] + }], + //This can always be the same if one is doing RGB images + output: { bands: 3 }, + mosaicking: "ORBIT" + } +} + +/* +In this function we limit the scenes, which are used for processing. +These are based also on input variables. +E.g. if one sets date "2017-03-01" ("TO date") and cloud coverage filter 30%, +all scenes older than 2017-03-01 with cloud coverage 30% will be checked against +further conditions in this function (in this function it is currently limited to 3 months). +The more scenes there are, longer it will take to process the data. +After 60 seconds of processing, there will be a timeout. +*/ + +function preProcessScenes (collections) { + collections.scenes.orbits = collections.scenes.orbits.filter(function (orbit) { + var orbitDateFrom = new Date(orbit.dateFrom) + return orbitDateFrom.getTime() >= (collections.to.getTime()-3*31*24*3600*1000); + }) + return collections +} + +function calcNDVI(sample) { + var denom = sample.Red + sample.NIR; + return ((denom != 0) ? (sample.NIR - sample.Red) / denom : NaN); +} +function evaluatePixel(samples) { + var max = 0; + for (var i= 0; i max ? ndvi:max; + return [max]; + } +} \ No newline at end of file