2

I'm working in QGIS 2.14.1 with a DEM ranging from 200 feet to 1600 feet elevation called "dem_3m_Zft1b" (geotiff, 16822 X 33349 cells, No-data =-9999)

If I enter

"dem_3m_Zft1b" > 0 

in the raster calculator I get a result that has a value of 0 everywhere in the raster extent. The calculator does not seem to recognize the existence of any values or of the no-data flag.

With a subset/portion of the DEM called "atest9b@1" (4489 X 6175 cells, No-data=-9999), If I enter "atest9b@1" > 0 in the raster calculator I get a result that has a value of 1 where there was data and a value of no-data where there was no-day. Everything seems OK when using the subset.

The larger DEM "dem_3m_Zft1b" seems OK in other ways, e.g. the "Identify" tool finds valid values for Band1, but the raster calculator doesn't seem to recognize the data in it.

I tried the same operation on the large DEM in the Processing Toolbox, SAGA, Raster Calculator with the syntax: g1 > 0 and I get the correct results, i.e. 1 where there is data and no-data where there isn't.

Any ideas or is QGIS 2.14.1 having a problem with the raster calculator?

1
  • I've had the same problem. I'm using QGIS 2.18.2, and I've gotten all-zero rasters when doing various raster math calculations, usually subtracting one raster from another. Similarly, these calculations work fine if I work with a smaller area. Most recently, I tried rasterizing a large vector file, and found that it would work fine for lower-resolution rasterization, but not higher-resolution. My assumption is that there's some silent failure related to too-little memory, but I'm not sure how to test this.
    – Hig
    Mar 31, 2017 at 21:50

1 Answer 1

1

I am wondering if the expression itself is correct or not. I think the expression should be "dem_3m_Zft1b@1" > 0 not "dem_3m_Zft1b" > 0. I think you need to specify the band number. In case of DEM, it is only one band which I think you need to add @1. In case of a subset DEM called "atest9b@1", the @1 was already included in the raster variable name, that is why it was succeeded. Could you try with "dem_3m_Zft1b@1" > 0 if it will give you a valid result?

Update

I will share what I found regarding the raster calculator. I tested the raster calculator of QGIS 2.8.8 using a DEM to extarct elevations above or equal to 500 m "Test@1" >= 500 with a dimension of 38542 x 60251 (ERDAS *.img format), which is 2 times larger than the image you have, and it works perfectly.

However, when I tested the raster calculator of QGIS 2.14.1 on same DEM image with the same dimensions to do the same raster calculation of "Test@1" >= 500, QGIS 2.14.1 crashed, as you can see below:

enter image description here

Maybe there is a bug in QGIS 2.14.1 with large images, because it also works without problems in small images. Try to use the LTR of QGIS 2.8.8 to see if it works with you.

2
  • Thanks for pointing out the missing @1. I don't know how the @1 got lost from my posting but, in any case, the result is the same with "dem_3m_Zft1b@1" > 0 or "dem_3m_Zft1b" > 0 both generate a raster of all 0.
    – user71212
    Apr 14, 2016 at 17:40
  • I updated my answer for more details.
    – ahmadhanb
    Apr 15, 2016 at 1:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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