Learn R Programming

OpenStreetMap (version 0.4.1)

plot.OpenStreetMap: Plot an OpenStreetMap object.

Description

Plot an OpenStreetMap object.

Usage

# S3 method for OpenStreetMap
plot(x, y = NULL, add = FALSE, removeMargin = TRUE, ...)

Arguments

x

the OpenStreetMap

y

ignored

add

add to current plot

removeMargin

remove margins from plotting device

...

additional parameters to be passed to plot

Examples

Run this code
if (FALSE) {
#
#	The following examples
#	plot using native mercator coordinates,
#	transforming the data where needed
#
library(sp)
m <- c(25.7738889,-80.1938889)
j <- c(58.3019444,-134.4197222)
miami <- projectMercator(25.7738889,-80.1938889)
jun <- projectMercator(58.3019444,-134.4197222)
data(states)
map <- openmap(j,m,4,type="esri-terrain")
plot(map,removeMargin=FALSE)
plot(states,add=TRUE)

data(LA_places)
longBeachHarbor <- openmap(c(33.760525217369974,-118.22052955627441),
	c(33.73290566922855,-118.17521095275879),14,'osm')
coords <- coordinates(LA_places)
x <- coords[,1]
y <- coords[,2]
txt <- slot(LA_places,"data")[,'NAME']
plot(longBeachHarbor)
points(x,y,col="red")
text(x,y,txt,col="white",adj=0)

}

Run the code above in your browser using DataLab