R/fortify_shape.R

Defines functions fortify_shape

Documented in fortify_shape

##' Sets shape data up for plotting
##'
##' Taken from https://rpubs.com/danielequs/199150
##' @title fortify_shape
##' @param x Output from readOGR or similar
##' @return A data frame
##' @author https://rpubs.com/danielequs/199150
##' @importFrom dplyr inner_join
##' @importFrom ggplot2 fortify
##' @export
fortify_shape <- function(x) {

    ## Helper function. From https://rpubs.com/danielequs/199150
    
    x@data$id <- rownames(x@data)
    x.f <- fortify(x, region = "id")
    x.join <- inner_join(x.f, x@data, by = "id")
}
NRM-MOC/MoCiS documentation built on March 27, 2023, 7:35 p.m.