Skip to main content

Hello,


I have something that puzzle me a lot.


I use the same custom script to generate images from the same position, one time with the SentinelHub playground, one other with the WMS API, and I do not get the same result.


The script is this one :
github.com

sentinel-hub/custom-scripts/blob/master/sentinel-2/ndvi_anomaly_detection/ndvi_anomaly_detection_script.js


/*
Author: Jean-Baptiste Pleynet
*/

const config2 = {
default: {
nbPastYears: 3,
defaultOutputValue: -2,
ndviMinValue: -1,
currentIndexesMinValuesNumber: 1,
pastIndexesMinValuesNumber: 3
},
ndviAnomaly: {
pixelEvalMaxValue: 0.7
},
loss: {
lowerTriggerPremium: 0,
higherTriggerPremium: 1,
minimumAverageValuePremium: 0.1,
minimumPayoutPremium: 0


This file has been truncated. show original




When I use it in the playground, I have some images : https://apps.sentinel-hub.com/sentinel-playground-temporal/?source=S2&layers=B04,B03,B02&gain=1.0&gamma=1.0&atmFilter=&showDates=false&zoom=14&lat=10.10935&lng=78.44619&maxcc=100&time=2015-01-01|2019-06-30&preset=CUSTOM&temporal=true&evalscripturl=https%3A%2F%2Fraw.githubusercontent.com%2Fsentinel-hub%2Fcustom-scripts%2Fmaster%2Fsentinel-2%2Fndvi_anomaly_detection%2Fndvi_anomaly_detection_script.js


When I use it in an API call, I do not get the same result (black image) : http://services.sentinel-hub.com/ogc/wms/?SERVICE=WMS&REQUEST=GetMap&SHOWLOGO=false&VERSION=1.3.0&CRS=EPSG:4326&temporal=true&LAYERS=TRUE_COLOR&MAXCC=100&WIDTH=512&HEIGHT=512&FORMAT=image/jpeg&BBOX=10.0688437282933,78.4056837282933,10.1498562717067,78.4866962717067&TIME=2019-06-30&EVALSCRIPTURL=https%3A%2F%2Fraw.githubusercontent.com%2Fsentinel-hub%2Fcustom-scripts%2Fmaster%2Fsentinel-2%2Fndvi_anomaly_detection%2Fndvi_anomaly_detection_script.js


What am I doing wrong or different ?

Maybe one hint.


I have change “filterScenes” function by :

const filterScenes = (scenes, metadataInput, nbPastYears) => {


var tmpString = "Number of scenes : " + scenes.length + " | "

for(let i = 0 ; i < scenes.length ; i++) {

tmpString = tmpString + " | " + scenesei].date

}

throw new Error(tmpString)


return scenes.filter((scene) => scene.date.getMonth() === metadataInput.to.getMonth()

&& scene.date.getFullYear() >= metadataInput.to.getFullYear() - nbPastYears)

}


It return 36 scenes, all in 2019.


How can I have access to older scenes ? The script need it to run.


The period of processing is defined with TIME parameter in the call.

TIME parameter should be constructed as “FROM/TO”. If you only pass one parameter, e.g. TIME=2019-06-30, we truncate it to “TO-6 months/TO”.

So to get older imagery you should use TIME=2018-01-01/2019-06-30


Great !

Just the time to find that “/” is “%2F”.

Thank you very much


Reply