[Qgis-user] QGIS Raster Calculator - cannot add two mutually exclusive areas with logical statement because nodata excludes the other's data

robertlozar robertlozar at netzero.com
Mon Jun 1 15:09:41 PDT 2015


I cannot figure out how to overcome the QGIS raster calculators rules.  

I need to calculate the Leaf Area Index -LAI- from satellite image bands.
The LAI is dependent on the Land Cover -LC - 

Type.  For each LC, I need to result in 3 mutually exclusive conditions: 
LAI > 0, then calculate the value
LAI < 0, set the value to zero (or a vanishingly small positive number)
Not current LandCover, set the value to nodata.
Then each different LC will be exclusive of all others.  So I will have to
add many mutually exclusive areas together.

I have written the equations as above for each of the landcover types
separately.  All I have to do is add one to the 

next to get a map of LAI for the three conditions and then for all the
landcovers. 

The problem is the QGIS Raster Calculator will not let me do the simple
addition.  It seems the reason is the nodata 

from the landcover type is what QGIS Raster Calculator is what takes
priority over the data in the addition and all I 

get is a final map full of nodata.  I cannot find a way of overcoming this
"feature".  I cannot believe such a simple 

action is not possible in any GIS.  Can someone point out where I am going
wrong?  

Thanks, Bob

Note-I have done this in GRASS and ArcGis and Iknow it can be done in SAGA
and the the QGIS plugings. Since the .tif 

format is the standard for QGIS, one should not have to put the images into
ascii format as some have suggested or use 

gdal_translate to get zeros and nodata separated (which does not work
anyhow). I am asking specifically about the QGIS 

Raster Calculator because I cannot believe it is not possible.

The actual equations I have been using look like this:
case 1 - calculates LAI for LC code 41 above zero correctly:  
(("nlcd_2011_benning_areawgs84z16.tif at 1"  = 41 ) AND
(("nlcd_2011_benning_areawgs84z16.tif at 1"  = 41 ) * ( 2.8 -102 * 

"clip_RT_LC80190382014318LGN00_B04 at 1"  + 28 
* "clip_RT_LC80190382014318LGN00_B05 at 1" - 41 * 
"clip_RT_LC80190382014318LGN00_B06 at 1" )     >=    0)) * ( 2.8 -102 *
"clip_RT_LC80190382014318LGN00_B04 at 1"  + 28 * 

"clip_RT_LC80190382014318LGN00_B05 at 1" - 41 * 
"clip_RT_LC80190382014318LGN00_B06 at 1" )

case 2 - calculates LAI for code 41 below zero to a small value correctly:  
(("nlcd_2011_benning_areawgs84z16.tif at 1"  = 41 ) AND
(("nlcd_2011_benning_areawgs84z16.tif at 1"  = 41 ) * ( 2.8 -102 * 

"clip_RT_LC80190382014318LGN00_B04 at 1"  + 28 
* "clip_RT_LC80190382014318LGN00_B05 at 1" - 41 * 
"clip_RT_LC80190382014318LGN00_B06 at 1" )     <=    0)) * .0000001

case 3 - set value for all codes NOT 41 to a vanishingly small number:
(("nlcd_2011_benning_areawgs84z16.tif at 1"  != 41 ) * .0000002)

So the final equation for Code 41 should be (but is NOT) as follows because 
    1. qgis does not allow you to add one layer to a second that is in the
seconds nodata area [same for + AND and OR 

between each] and 
    2. ("your_raster" != -32768) * "your_raster" does not work because image
data is UInt16 in which nodata value 

cannot be addressed (this statement may work for other formats)

The equation for Code 41
(( (("nlcd_2011_benning_areawgs84z16.tif at 1"  = 41 ) AND
(("nlcd_2011_benning_areawgs84z16.tif at 1"  = 41 ) * ( 2.8 -102 * 

"clip_RT_LC80190382014318LGN00_B04 at 1"  
+ 28 * "clip_RT_LC80190382014318LGN00_B05 at 1" - 41 * 
"clip_RT_LC80190382014318LGN00_B06 at 1" )     >=    0)) * ( 2.8 -102 *
"clip_RT_LC80190382014318LGN00_B04 at 1"  + 28 * 

"clip_RT_LC80190382014318LGN00_B05 at 1" - 
41 * 
"clip_RT_LC80190382014318LGN00_B06 at 1" ) )  OR
((("nlcd_2011_benning_areawgs84z16.tif at 1"  = 41 ) AND 

(("nlcd_2011_benning_areawgs84z16.tif at 1"  = 41 ) * ( 2.8 -102 *
"clip_RT_LC80190382014318LGN00_B04 at 1"  
+ 28 
* "clip_RT_LC80190382014318LGN00_B05 at 1" - 41 * 
"clip_RT_LC80190382014318LGN00_B06 at 1" )     <=    0)) * .0000001  ) OR  
(("nlcd_2011_benning_areawgs84z16.tif at 1"  != 

41 ) *  (.0000002 )  ) )



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/QGIS-Raster-Calculator-cannot-add-two-mutually-exclusive-areas-with-logical-statement-because-nodataa-tp5208547.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.



More information about the Qgis-user mailing list