ihernandez
(Ignacio Hernandez)
September 3, 2020, 8:21pm
#1
Hello, i’m getting 0 to 250 tiff values when I run this Layer script in QGIS.
What should I add to get -1 to +1 values as index?
Regards
//VERSION=3
function evaluatePixel(samples) {
let val = 2.5 * (samples.B08 - samples.B04) / (samples.B08 + 6 * samples.B04 - 7.5 * samples.B02 + 1);
return [val, samples.dataMask];
}
function setup() {
return {
input: [{
bands: [
“B02”,
“B04”,
“B08”,
“dataMask”
]
}],
output: {
bands: 2
}
}
}
avrecko
(avrecko)
September 4, 2020, 10:56am
#2
Hi ihernandez ,
to get values between -1 and 1 you need to specify sampleType: "FLOAT32"
. E.g.:
//VERSION=3
function evaluatePixel(samples) {
let val = 2.5 * (samples.B08 - samples.B04) / (samples.B08 + 6 * samples.B04 - 7.5 * samples.B02 + 1);
return [val, samples.dataMask];
}
function setup() {
return {
input: [{
bands: [
"B02",
"B04",
"B08",
"dataMask"]
}],
output: {
bands: 2,
sampleType: "FLOAT32"
}
}
}
More info in the SH documentation: sampleType
I am not sure how exactly you are using this in Qgis. To get float values you might need to add a WCS layer.
ihernandez
(Ignacio Hernandez)
September 8, 2020, 5:01pm
#3
Thanks it worked! I work always with WMS and its fine. I don’t know whats the different between WCS and WMS. In QGIS I use the Plugin to search for images and download from there.
Regards. Jose