R/null_raster_polygon.R

Defines functions null_raster_polygon

Documented in null_raster_polygon

#' Create a Spatial polygon Data Set from a shape file
#' with an arbitrary resolution
#'
#' @param shp A shape file
#' @param res A resolution vector of the null raster in geographical degrees
#' @importFrom raster raster res rasterToPolygons crop
#'
#' @return a null polygon
#' @export
#'
#' @examples null_raster_polygon(shp = mexico, res = 1)
null_raster_polygon <- function(shp, res){
  x <- raster::raster()
  raster::res(x) <- c(res, res)
  xcrop <- raster::crop(x, shp)
  xpolygon <- raster::rasterToPolygons(xcrop)
  return(xpolygon)
}
alrobles/geotax documentation built on July 27, 2023, 4:37 a.m.