Learn R Programming

modiscloud (version 0.14)

sum_bitgrid: Take a series of byte tifs, extract the values of a bit, and add them up

Description

This function is useful if you have a series of cloud product byte tifs, and need to extract a bit from each, and then add up (e.g. to get the total number of cloudy observations).

Usage

sum_bitgrid(fns, numits = length(fns), bitnums, ydim_new, xdim_new, test_for_1 = 1)

Arguments

fns
A list of filenames which can be auto-read by readGDAL (e.g. geoTIFFs)
numits
Number of iterations to run for (default = length(fns))
bitnums
The bit(s) you would like to extract. If length(bitnums) = 1, do default behavior. If the length is 2, then run the alternative function.
ydim_new
The dimensions of the extracted image. This is REQUIRED, since each day of a MODIS image may have different pixel dimensions over the same location. readGDAL will sample each image (nearest neighbor pixel) to the correct dimensions.
xdim_new
The dimensions of the extracted image. This is REQUIRED, since each day of a MODIS image may have different pixel dimensions over the same location. readGDAL will sample each image (nearest neighbor pixel) to the correct dimensions.
test_for_1
What your extracted bit(s) should match. If 1 (default), just count up 1s. If a string, e.g. "!=11", use that in an if-then statement to get the 1s to count

Value

grdr_vals_bits, a matrix of 0/1 values for the bit in question

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

numslist_to_grd

Examples

Run this code
# See numslist_to_grd example for an idea of how this works.

Run the code above in your browser using DataLab