Last active
November 2, 2021 11:30
-
-
Save mlubej/28ba379ccf0be0b627ce1bb695d496fc to your computer and use it in GitHub Desktop.
A proof-of-principle Sentinel Hub Evalscript for detecting mowing events on the pixel level
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 | |
function setup() { | |
return { | |
input: ["B04", "B08", "CLP", "dataMask"], | |
output: {bands: 2, sampleType: SampleType.INT8}, | |
mosaicking: "ORBIT" | |
} | |
} | |
function evaluatePixel(samples, scenes) | |
{ | |
let dates = []; | |
let values = []; | |
for (let i = 0; i < samples.length; i++) { | |
var sample = samples[i]; | |
var scene = scenes[i]; | |
// define variables | |
let NDVI = index(sample.B08, sample.B04); | |
let CLP = sample.CLP/255.0; | |
let DM = sample.dataMask; | |
// keep non-cloudy obs. | |
if (CLP < CLP_THR && DM == 1) { | |
dates.push(scene.date); | |
values.push(NDVI); | |
} | |
var dataMask = 0; | |
var mowing_events = []; | |
if (dates.length > 0) { | |
dataMask = 1; | |
events = getMowingEvents(dates, values); | |
} | |
return [events.length, dataMask]; | |
} | |
function getMowingEvents(dates, values) | |
{ | |
// 1. find peaks & valleys | |
// 2. determine pixel-mowing candidates | |
// 3. apply filtering | |
// 4. ... | |
// 5. profit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment