An error occurred while loading the file. Please try again.
-
Dorchies David authored
Refs #4
#' Area of the polygons in SpatialPolygonsDataFrame
#'
#' Calculates the area of each polygon in [sp::SpatialPolygonsDataFrame].
#'
#' @param sp.object `SpatialPolygonsDataFrame`, must be a `SpatialPolygonsDataFrame` object
#'
#' @return a numeric vector
#'
#' @note Copied from the UScensus2010 package
#' @author Zack W. Almquist
#' @references Zack W. Almquist (2010). US Census Spatial and Demographic Data in R: The UScensus2000 Suite of Packages. Journal of Statistical Software, 37(6), 1-31. https://www.jstatsoft.org/v37/i06/.
#' @seealso https://rdrr.io/cran/UScensus2010/man/areaPoly.html
#' @export
#'
areaPoly <- function(sp.object = NULL) {
### Check to make sure the object is sp-class
if (class(sp.object)[1] != "SpatialPolygonsDataFrame")
cat("Incompatible class!")
area <-
sapply(methods::slot(sp.object, "polygons"),
methods::slot,
"area")
area
}