R/old/class-raster.extract.R

Defines functions new_raster.extract is.raster.extract

#' @name class-raster.extract
#' @aliases raster.extract
#'
#' @title Class "raster.extract" for raster data extraction
#'
#' @description A S3 class inheriting from class
#' \code{\link[glr:class-extract]{extract}} to store outputs stemming from
#' raster data extractions and manipulations.
#'
#' @usage
#' ## The constructor function
#' new_raster.extract(meta, output, miss.tiles, na.values, duplicates)
#'
#' @param meta An object of class \code{\link[glr:class-meta]{meta}}.
#'
#' @param output An array or a \code{\link{vector}}. Typically, a
#' \code{\link[data.table]{data.table}}, a \code{\link{data.frame}},
#' a \code{\link{list}} or a \code{\link{matrix}}. If a \code{\link{vector}},
#' classes \code{\link{complex}} and \code{\link{raw}} are not supported.
#'
#' @param miss.tiles An array or a \code{\link{vector}}. Typically, a
#' \code{\link[data.table]{data.table}}, a \code{\link{data.frame}},
#' a \code{\link{list}} or a \code{\link{matrix}}. If a \code{\link{vector}},
#' classes \code{\link{complex}} and \code{\link{raw}} are not supported.
#' Can be \code{NULL}.
#'
#' @param na.values An array. Typically, a named
#' \code{\link[data.table]{data.table}} object. Can be \code{NULL}.
#'
#' @param duplicates An array. Typically, a named
#' \code{\link[data.table]{data.table}} object. Can be \code{NULL}.
#'
#' @param x Any \R object.
#'
#' @details Class \code{\link[glr:class-raster.extract]{raster.extract}} is a
#' class \emph{inheriting} from class \code{\link[glr:class-extract]{extract}}.
#' For more information on S3 inheritance mechanism, see
#' \code{\link[base:class]{class}}. Usually, this class is used to structure
#' the output of any function performing operations on rasters. It is a wrapper
#' to \code{\link{new_extract}}.
#'
#' @return Function \code{\link{new_raster.extract}} is a constructor function:
#' it returns an object of class \code{raster.extract} from its arguments.
#' Function \code{\link{is.raster.extract}} checks if \code{x} is of class
#' \code{\link[glr:class-raster.extract]{raster.extract}} and returns a logical.
#' For the associated methods, the usual outputs should be expected.
#'
#' @section Components (slots):
#'
#' \describe{
#' \item{\code{meta}:}{
#' Information on the layers that were used for the extraction. See
#' \code{\link[glr:class-meta]{meta}}.
#' }
#' \item{\code{output}:}{
#' The extracted values from the layers.
#' }
#' \item{\code{miss.tiles}:}{
#' Base names of all unavailable tiles given as \code{character}. Can be
#' \code{NULL}. An unavailable tile either does not exist or cannot be read.
#' }
#' \item{\code{na.values}:}{
#' Information on spatial coordinates for which no extraction was done. Can
#' be \code{NULL}.
#' }
#' \item{\code{duplicates}:}{
#' Duplicates stemming from the extraction process. If more than one value is
#' extracted for a given coordinate, the maxima is always kept. This is a
#' usually a consequence of numerical inaccuracies. This component registers all
#' extracted values (when applicable).
#' }
#' }
#'
#' @section S3 methods for objects of class \code{raster.extract}:
#' None implemented. Methods for class \code{\link[glr:class-extract]{extract}}
#' are used through the inheritance mechanism.
#'
#' An object of class \code{\link[glr:class-raster.extract]{raster.extract}} is
#' stored as a list. Therefore, usual methods for lists such as
#' \code{\link[base:Extract]{[}}, \code{\link[base:Extract]{[[}},
#' \code{\link[base:Extract]{$}}, etc. will all work.
#'
#' @family extract classes
#' @family glr classes
#'
#' @export
new_raster.extract <- function(meta, output, miss.tiles, na.values, duplicates)
{
  new_extract(meta, output,
              miss.tiles = miss.tiles,
              na.values  = na.values,
              duplicates = duplicates,
              .subclass  = "raster.extract")
}

#' @rdname class-raster.extract
#' @export
is.raster.extract <- function(x)
{
  inherits(x, "raster.extract")
}
jeanmathieupotvin/scr documentation built on Dec. 3, 2019, 8:53 p.m.