sp2df: Transform data from sp to data frame for ggplot2

Description Usage Arguments Value Author(s) References Examples

View source: R/sp2df.R

Description

Transform data from sp to data frame for ggplot2

Usage

1
sp2df(sp, region = NULL, verbose = TRUE)

Arguments

sp

A spatial object to be transformed

region

A string specifying the region of interest

verbose

logical. Should R report extra information on progress?

Value

A ggplot2 theme object

Author(s)

Juuso Parkkinen louhos@googlegroups.com

References

See citation("gisfin")

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
sp.suuralue <- get_helsinki_aluejakokartat(map.specifier="suuralue");
          # Need to load rgeos and maptools for ggplot2::fortify in sp2df() 
          library(rgeos);
          library(maptools);
          # Transform to df and plot with ggplot2
          df.suuralue <- sp2df(sp.suuralue, "Name");
          library(ggplot2);
          theme_set(get_theme_map());
          ggplot(df.suuralue, aes(x=long, y=lat, fill=Name)) + 
          geom_polygon() + theme(legend.position="none")

rOpenGov/gisfin documentation built on May 26, 2019, 8:48 p.m.