R/label_cfa.R

Defines functions label_cfa

#' Label color filter array (CFA)
#'
#' @param r [SpatRaster-class].
#' @inheritParams read_caim
#'
#' @return [SpatRaster-class].
#' @noRd
label_cfa <- function(r,
                      upper_left = NULL,
                      width = NULL,
                      height = NULL) {
  .is_single_layer_raster(r)
  stopifnot(.is_even(ncol(r)/2))
  stopifnot(.is_even(nrow(r)/2))
  r[] <- c(rep(c(0,1), ncol(r)/2), rep(c(2,3), ncol(r)/2)) %>% rep(., nrow(r)/2)
  crop_caim(r, upper_left, width, height)
}

Try the rcaiman package in your browser

Any scripts or data that you put into this service are public.

rcaiman documentation built on Nov. 15, 2023, 1:08 a.m.