autoplot.OpenStreetMap: Plot an open street map using ggplot2

View source: R/autoplot.R

autoplot.OpenStreetMapR Documentation

Plot an open street map using ggplot2

Description

Plot an open street map using ggplot2

Usage

## S3 method for class 'OpenStreetMap'
autoplot(object, expand = TRUE, ...)

Arguments

object

an OpenStreetMap object

expand

if true the plotting bounds are expanded to the bounding box

...

not used

Examples

## Not run: 
require(maps)
require(ggplot2)

mp <- openmap(c(53.38332836757155,-130.517578125),
		c(15.792253570362446,-67.939453125),4)
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)

## End(Not run)

OpenStreetMap documentation built on Oct. 12, 2023, 5:15 p.m.