2

I am trying to extract Vegetation from an aerial image.

First I calculated a DEM for vegetation height and a binary image (0,1) for cover. Then I divided DEM by binary. Result was a raster with vegetation height data and “no-data”, which is what I want. This worked very well, until recently.

Suddenly I get “inf” instead of no data. I even tried to reproduce previous results and this is now happening there as well. I honestly have no idea what has changed. To reproduce the previous calculations I used raster images that definitely have worked before, but now they do not.

Has anyone any idea how I can get back my “no data” again? Alternatively how to deal with inf?

1
  • the result of dividing by 0 is often represented by inf or nan but it can be just about anything. Maybe you could multiply by the binary instead
    – Ian Turton
    Jan 10 at 15:54

2 Answers 2

1

Approach

You may want to convert this inf value to Nan or NoData. you can easily do it by running raster operation like Self equals. x==x

  1. For all real values, this will be True.
  2. For all Nans, NoData, or Inf, -Inf. This will be False.

So you will get a binary raster.

2
  • Thanks for the input. I was so troubled that I am actually reinstalling qgis right now, so I can't try it. You write I'll get a binary raster, does this mean that I consequently lose the vegetation height data? But I need to keep these values.
    – Kaymahn
    Jan 10 at 13:44
  • @ManishSahu: Self equals does not work in QGIS raster calculator : "raster@1" == "raster@1" shows Expression invalid. Using "raster@1" = "raster@1", fol nodata the result remains nodata
    – Babel
    Jan 10 at 13:52
0

Well I don't know why the raster calculator did not work, why saga calculator did not work. But using the grass r.mapcalc.simple did work.

I literally did not change anything but the calculator and got my result.

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.