apply function (Bitwise "and") on each cell of a raster in R? -
what best way "bitwise and" on pixels in raster (maybe using "raster" package)? want check if sixth bit set.
if given integer, use r's bitwand operator. 'and' 32 (has sixth bit set) , see if result 0 or otherwise. example: bitwand(96,32) # 32, has sixth bit set bitwand(192,32) # 0, not have sixth bit set
i tried bitwand(myraster,32l) not work.
thanks! r.
for operations on each cell of raster, can use function calc
of library raster
. in case, be:
r.test <- calc(myraster, fun = function(x) bitwand(x,32l))
Comments
Post a Comment