OpenStreetMap (version 0.3.4)

autoplot.OpenStreetMap: Plot an open street map using ggplot2

Description

Plot an open street map using ggplot2

Usage

# S3 method for OpenStreetMap
autoplot(data, expand = TRUE, ...)

Arguments

data

an OpenStreetMap object

expand

if true the plotting bounds are expanded to the bounding box

...

not used

Examples

Run this code
if (FALSE) {
require(maps)
require(ggplot2)

mp <- openmap(c(53.38332836757155,-130.517578125),
		c(15.792253570362446,-67.939453125),4,'stamen-watercolor')
mp_bing <- openmap(c(53.38332836757155,-130.517578125),
		c(15.792253570362446,-67.939453125),4,'bing')
states_map <- map_data("state")
states_map_merc <- as.data.frame(
		projectMercator(states_map$lat,states_map$long))
states_map_merc$region <- states_map$region
states_map_merc$group <- states_map$group
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)

p <- autoplot(mp,expand=FALSE) + geom_polygon(aes(x=x,y=y,group=group),
		data=states_map_merc,fill="black",colour="black",alpha=.1) + theme_bw()
print(p)
p <- autoplot(mp_bing) + geom_map(aes(x=-10000000,y=4000000,map_id=state,fill=Murder),
		data=crimes,map=states_map_merc)
print(p)
}

Run the code above in your browser using DataLab