R/fortify2.R

Defines functions fortify2

#' fortify2
#'
#' convert sp to dataframe
#'
#' @param x spatial polygon data
#'
#' @return data frame
#' @export
#'
#' @examples
fortify2  <- function(x) {
  require(rgdal)
  temp <- fortify(x)
  temp$id <- as.numeric(temp$id)
  x@data$id <- 0:(nrow(x@data)-1)
  y <- left_join(temp, x@data, by = "id")
  return(y)
}
gabrielzanlorenssi/extfunctions documentation built on Dec. 30, 2019, 6:37 p.m.