4

I have a DEM like below image. The black area shows 0-values.

I want to remove cells of 0-values in the raster.  

Example

In raster calculator, I wrote con("demclip_re@1">0,"demclip_re@1") but it gives "Incorrect expression".

What is wrong with my expression?

Taras
  • 32,823
  • 4
  • 66
  • 137
Jung TaeJun
  • 139
  • 1
  • 5

3 Answers3

6

Con is an ArcGIS raster tool which is not available in QGIS.

If you want to replace all 0 value cells with nodata, you could use something like:

("demclip_re@1") / ("demclip_re@1">0)
Joseph
  • 75,746
  • 7
  • 171
  • 282
2

If your area of interest is also available as a vector layer, you could use "Clip Raster by Mask Layer" tool in QGIS and make sure you select the option to "Create output alpha band".

This will also help keep your file size from getting too large in comparison to the raster calculator options above.

user2031
  • 221
  • 1
  • 13
1

I've tested the ("demclip_re@1") / ("demclip_re@1">0) and it worked almost perfectly. The only problem in my case was that it also excluded negative values and I wanted only 0 values excluded. Therefore, the best solution for me was:

("demclip_re@1") / ("demclip_re@1" != 0)
MrXsquared
  • 34,292
  • 21
  • 67
  • 117