Learn R Programming

modiscloud (version 0.14)

byteint2bit: Convert a byte integer (0-255) to a list of 8 bits

Description

MODIS HDFs converted to tifs result in each pixel having a integer value from 0 to 255. byteint2bit converts this to a string of 8 bits (0/1 values).

Usage

byteint2bit(intval, reverse = TRUE)

Arguments

intval,
an integer between 0 and 255
reverse,
a logical (TRUE/FALSE) indicating whether or not the string of bits should be reversed. Default: TRUE

Value

byte_in_binary, the 8 bits (0/1 values) in the correct order

Details

In the case of MODIS, the bits are read from RIGHT to LEFT, which is unnatural, so by default the function uses rev() to reverse the order of reading.

Note: the reversal means that, when interpreting the two 2-bit strings in the MODIS image, the interpretation of 01 and 10 is reversed from in the MODIS documentation.

References

Ackerman S, Frey R, Strabala K, Liu Y, Gumley L, Baum B and Menzel P (2010). "Discriminating clear-sky from cloud with MODIS algorithm theoretical basis document (MOD35)." MODIS Cloud Mask Team, Cooperative Institute for Meteorological Satellite Studies, University of Wisconsin - Madison. .

GoldsmithMatzkeDawson2013

See Also

extract_bit

byteint2bit_list

Examples

Run this code
byteint2bit(intval=0, reverse=FALSE)
byteint2bit(intval=0, reverse=TRUE)
byteint2bit(intval=1, reverse=FALSE)
byteint2bit(intval=1, reverse=TRUE)
byteint2bit(intval=254, reverse=FALSE)
byteint2bit(intval=254, reverse=TRUE)
byteint2bit(intval=255, reverse=FALSE)
byteint2bit(intval=255, reverse=TRUE)

Run the code above in your browser using DataLab