myraster = raster(matrix(0,10,10),xmn=0,xmx=10,ymn=0,ymx=10)
plot(myraster)
# only do the following if running unix (because nsl is available)
# and if the OpenStreetMap.org web site can be accessed
if(.Platform$OS.type=="unix") {
if(length(utils::nsl("www.OpenStreetMap.org"))) {
mytiles = openmap(myraster@extent, zoom=4, type="osm")
plot(myraster)
plot(mytiles, add=TRUE)
mypoints = SpatialPoints(10*cbind(runif(10), runif(20)))
mytiles=openmap(mypoints@bbox, zoom=4, type="bing")
plot(mypoints)
plot(mytiles,add=TRUE)
points(mypoints, col='yellow')
}
}
Run the code above in your browser using DataLab