1

I'm trying to calculate the NDVI using raster calculator, but the result is integer instead of decimal.

NDVI = (NIR - RED)/(NIR + RED)

The result is normally in the range -1 to 1, but when i tried to calculate de result is -1, 0 and 1, and it does not have have any number in between like, -0.9 or 0.1. And i need those values so i can classify the result in term of soil occupation

3
  • 3
    It would help if you posted your Raster Calculator expression.
    – crmackey
    Commented Nov 18, 2014 at 15:43
  • 3
    Is you raster pixel type floating point?
    – FGoodison
    Commented Nov 18, 2014 at 16:27
  • You need to add more information! Please Edit your question with your calculation expression and sample data. Short one line questions are generally deleted from this site. Commented Nov 19, 2014 at 0:50

1 Answer 1

12

Pixel depth begets pixel depth. If you are using digital numbers as your input to the NDVI expression then the result will be integer. You will need to explicitly coerce to float in the raster algebra expression.

Float("nir" - "red") / Float("nir" + "red") 
2
  • 3
    Just a note (to be as lazy as possible) that you don't need to specify everything as a float to get a float in the end (float combined with integer results in float). You will get the same result only changing one instance of one of the rasters to a float: (Float("nir") - "red")/("nir" + "red")
    – phloem
    Commented Nov 18, 2014 at 18:05
  • 1
    To be safe, I would check the precision of NOT coercing to float on both sides of the equation. You may get some unexpected results, or not. Commented Nov 18, 2014 at 21:33

Your Answer

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

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