Description Usage Arguments Details Value Author(s) References See Also Examples
Some MODIS cloud products have 2-bit codes, e.g. the MOD35_L2 product has a 2-bit code specifying the 4 possible outputs of the cloud-classification algorithm: confident cloudy, probable cloudy, probable clear, confident clear.
1 | get_bitgrid_2bits(grd, bitnums)
|
grd |
A SpatialGridDataFrame, derived from e.g. readGDAL |
bitnums |
The bit you would like to extract |
Note: this means that, when interpreting the two 2-bit strings in the MODIS image, you have to reverse the bit order. This is done by default here.
grdr_vals_bitstrings
, a list of strings for the
bits in question (string, e.g. "11" or "01" or "00")
Nicholas J. Matzke matzke@berkeley.edu
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. <URL: http://modis-atmos.gsfc.nasa.gov/_docs/MOD35_ATBD_Collection6.pdf>.
GoldsmithMatzkeDawson2013
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #######################################################
# Load a TIF
#######################################################
# Code excluded from CRAN check because it depends on modiscdata
## Not run:
library(devtools)
# The modiscdata (MODIS c=cloud data=data) package is too big for CRAN (60 MB); so it is available on github:
# https://github.com/nmatzke/modiscdata
# If we can't get install_github() to work, try install_url():
# install_github(repo="modiscdata", username="nnmatzke")
install_url(url="https://github.com/nmatzke/modiscdata/archive/master.zip")
library(modiscdata)
tifsdir = system.file("extdata/2002tif/", package="modiscdata")
tiffns = list.files(tifsdir, pattern=".tif", full.names=TRUE)
tiffns
library(rgdal) # for readGDAL
# numpixels in subset
xdim = 538
ydim = 538
# Read the grid and the grid metadata
coarsen_amount = 1
xdim_new = xdim / floor(coarsen_amount)
ydim_new = ydim / floor(coarsen_amount)
fn = tiffns[1]
grd = readGDAL(fn, output.dim=c(ydim_new, xdim_new))
grdproj = CRS(proj4string(grd))
grdproj
grdbbox = attr(grd, "bbox")
grdbbox
#######################################################
# Extract a particular pair of bits for all the pixels in the grid
#######################################################
bitnum = 2
grdr_vals_bitstrings = get_bitgrid_2bits(grd, bitnum)
length(grdr_vals_bitstrings)
grdr_vals_bitstrings[1:50]
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.