semiautomaticgit / SemiAutomaticClassificationPlugin

https://fromgistors.blogspot.com/p/semi-automatic-classification-plugin.html
Other
137 stars 50 forks source link

Band calc no data value not respected #40

Closed jgrocha closed 6 years ago

jgrocha commented 6 years ago

Hi, I've set the the No data value to -999 in the Band calc dialog.

captura de ecra de 2018-06-12 11-59-11

After computing the indexes, the No data value is 0, instead of -999.

captura de ecra de 2018-06-12 12-00-41

Is somebody able to reproduce the problem? I'll check the code later, to check if this No data value is used or not.

semiautomaticgit commented 6 years ago

Hi, the nodata value is the value considered as NoData. Therefore, if the calculation result is 0, you should set 0 as NoData value.

jgrocha commented 6 years ago

Thanks for the feedback @semiautomaticgit I'm sorry, but I didn't understood your point.

When I create and index, NDVI for example, the values are in the range [-1, 1]. So, I can have values computed as 0, if NIR is equal to RED. I don't want 0 as the "no data value" on the output, because 0 can be a valid output. For pixels in the resulting raster, where we don't have input values, the output should be the "no data value" specified, right?

By other words: how do I say that the "no data value" in the output should be -999 instead of 0 (zero)?

In the above screenshot, for the NDWI index (layer NDWI_20180606.tif) there is black area below. All these pixels have the value 0. I would prefer to have the value -999.

semiautomaticgit commented 6 years ago

The plugin Band calc performs the calculation for all the pixels (also NoData) in the original bands. Set NoData is used to set a NoData value of the output raster (e.g. all the pixels resulting -999 are set NoData). If you need to exclude the black are you should perform a conditional calculation with the condition "where" and define the NoData value accordingly, such as the following expression: where( "bandset#b1" == nodata("bandset#b1") , -999, ("bandset#b2" - "bandset#b1" ) / ("bandset#b2" + "bandset#b1" ))

jgrocha commented 6 years ago

I'll check the code to understand how it can be used.