Learn R Programming

ggplot2 (version 3.3.1)

fortify.sp: Fortify method for classes from the sp package.

Description

To figure out the correct variable name for region, inspect as.data.frame(model).

Usage

# S3 method for SpatialPolygonsDataFrame
fortify(model, data, region = NULL, ...)

# S3 method for SpatialPolygons fortify(model, data, ...)

# S3 method for Polygons fortify(model, data, ...)

# S3 method for Polygon fortify(model, data, ...)

# S3 method for SpatialLinesDataFrame fortify(model, data, ...)

# S3 method for Lines fortify(model, data, ...)

# S3 method for Line fortify(model, data, ...)

Arguments

model

SpatialPolygonsDataFrame to convert into a dataframe.

data

not used by this method

region

name of variable used to split up regions

...

not used by this method

Examples

Run this code
# NOT RUN {
if (require("maptools")) {
 sids <- system.file("shapes/sids.shp", package="maptools")
 nc1 <- readShapePoly(sids,
   proj4string = CRS("+proj=longlat +datum=NAD27"))
 nc1_df <- fortify(nc1)
}
# }

Run the code above in your browser using DataLab