[GRASS-user] help to use r.mapcalc with decimal/binary (modis data)

Glynn Clements glynn at gclements.plus.com
Fri May 25 19:32:28 EDT 2007


andrew.haywood at poyry.com wrote:

>   when i try and create a mask using this raster i use the
>
>   r.mapcalc MASK="if(sur_refl_qc_250 & 0x00F0 == 0x00B0 , 1, null())"
>
>   and i get the following error
>
>   syntax error, unexpected NAME, expecting ')'

Oops; I could have sworn that r.mapcalc understood hex. Sorry; you'll
need to use decimal values, e.g.

r.mapcalc MASK="if(sur_refl_qc_250 & 240 == 176 , 1, null())"

>  I am assuming that is because the hex code is assuming the data is in
>  binary when in fact it is in decimal.

No, computers store data in binary. Values are normally displayed as
decimal, but that has nothing to do with internal representation or
calculations.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list