3

I'm strugling with the QGIS Raster Calculator, trying to get a NDVI image from a Landsat 8 scene (path 222, row 84, date 2015-11-15). The problem is, I'm consistently getting NaN values for all the resulting pixels.

As far as I can tell, everything I'm doing should be right: projections, data type, dimensions, origin, etc, are the same (which is expected from a landsat scene)(see below). The formula used is just

(B5 - B4) / (B5 + B4)

or, expressed in terms of my layers:

( "LC82220842015319LGN00_B5@1" - "LC82220842015319LGN00_B4@1" )  /  ( "LC82220842015319LGN00_B5@1" + "LC82220842015319LGN00_B4@1" ) 

As I mentioned before, all I get is a raster layer with all pixels NaN.

A couple of observations:

  • I had no problems with the landsat 8 scene for row 222 path 83, for the same date.

  • The NaNs somehow occur because of the numerator, but not the denominator... In other words: B5 + B4 works good, but B5 - B4 gives NaN.

So, it's really just the difference operation that works badly.


Metadata from the layers:

B5:

Driver
GDAL provider
GTiff
GeoTIFF
Dataset Description
/home/jmb/Ramsar_2016/SIG/Landsat/222_084/LC82220842015319LGN00/LC82220842015319LGN00_B5.TIF
AREA_OR_POINT=Point
Band 1
STATISTICS_MAXIMUM=31568
STATISTICS_MEAN=7466.8914366775
STATISTICS_MINIMUM=0
STATISTICS_STDDEV=7611.703054711
Dimensions
X: 7911 Y: 7981 Bands: 1
Origin
646785,-3.71428e+06
Pixel Size
30,-30
No Data Value
*NoDataValue not set* 
Data Type
UInt16 - Sixteen bit unsigned integer 
Pyramid overviews
Layer Spatial Reference System
+proj=utm +zone=21 +datum=WGS84 +units=m +no_defs
Layer Extent (layer original source projection)
646785.0000000000000000,-3953715.0000000000000000 : 884115.0000000000000000,-3714285.0000000000000000
Band
Band 1
Band No
1
No Stats
No stats collected yet 

B4:

Driver
GDAL provider
GTiff
GeoTIFF
Dataset Description
/home/jmb/Ramsar_2016/SIG/Landsat/222_084/LC82220842015319LGN00/LC82220842015319LGN00_B4.TIF
AREA_OR_POINT=Point
Band 1
STATISTICS_MAXIMUM=24844
STATISTICS_MEAN=4926.3172446242
STATISTICS_MINIMUM=0
STATISTICS_STDDEV=3631.9117068848
Dimensions
X: 7911 Y: 7981 Bands: 1
Origin
646785,-3.71428e+06
Pixel Size
30,-30
No Data Value
*NoDataValue not set* 
Data Type
UInt16 - Sixteen bit unsigned integer 
Pyramid overviews
Layer Spatial Reference System
+proj=utm +zone=21 +datum=WGS84 +units=m +no_defs
Layer Extent (layer original source projection)
646785.0000000000000000,-3953715.0000000000000000 : 884115.0000000000000000,-3714285.0000000000000000
Band
Band 1
Band No
1
No Stats
No stats collected yet

Update 1: my version of QGIS when first asked this question:

QGIS version    2.8.6-Wien  QGIS code revision  exported
Compiled against Qt 4.8.7   Running against Qt  4.8.7
Compiled against GDAL/OGR   1.11.3  Running against GDAL/OGR    1.11.3
Compiled against GEOS   3.5.0-CAPI-1.9.0    Running against GEOS    3.5.0-CAPI-1.9.0 r4084
PostgreSQL Client Version   9.5.1   SpatiaLite Version  4.3.0a
QWT Version 6.1.2   PROJ.4 Version  492
QScintilla2 Version 2.9.1

Update 2 (SOLVED, sort of): My current version is 2.14.3-Essen

The solution somehow involves dealing with the projections, but I'm not sure what exactly it's going on. To make it short, I just started a new project in qgis, imported the landsat 8 .tiffs layers and used raster calculator to get the NDVI.

It's still intriguing what I got in my main project though. When I make the calculations, I get the correct result, but only in a small region (gray area)(note that on the sides, the region was cropped beforehand to make my layers smaller. This does not explain the southern horizontal limit though):

The good result in colors, the bad one in B&W

3

There is no problem in the Landsat data nor the Raster Calculator. The raster calculator worked smoothly without giving any invalid result. I downloaded your Landsat 8 image and calculated the NDVI using QGIS 2.14.2 Essen. I also tested the raster calculator of QGIS LTR 2.8.9, and both of them gave the same result. You can see the output of the calculated NDVI below:

enter image description here

And you can see below the NDVI equation in the raster calculator:

enter image description here

If you have an old version of QGIS, try to update it to the latest QGIS LTR release OR QGIS 2.14.3.

Another thing to try is to change the output format (here I used ERDAS Imageine .img) as an output format. Sometimes the output format can cause a problem.

  • Ok, I have QGIS 2.8.6 Wien, so that could be the problem. Anyways, there's no installer of 2.14.3 Essen for my distro (Ubuntu 16.04, Xenial), apparently. The output format didn't work as well. – Juan May 31 '16 at 17:06
  • Try to install QGIS on Windows OS if you have access to PC with Windows OS, and check if QGIS Windows version can solve your problem. – ahmadhanb Jun 2 '16 at 13:58
  • I found a way to update to QGIS 2.14.3 in ubuntu. The result is in "Update 2". Thanks for the help. – Juan Jun 2 '16 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.