openproj | R Documentation |
Projects the open street map to an alternate coordinate system
openproj(x, projection = "+proj=longlat", ...)
x |
an OpenStreetMap object |
projection |
a proj4 character string or CRS object |
... |
additional parameters for projectRaster |
## Not run:
library(maps)
#plot bing map in native mercator coords
map <- openmap(c(70,-179),
c(-70,179),zoom=1,type='bing')
plot(map)
#using longlat projection lets us combine with the maps library
map_longlat <- openproj(map)
plot(map_longlat)
map("world",col="red",add=TRUE)
#robinson projection. good for whole globe viewing.
map_robinson <- openproj(map_longlat, projection=
"+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
plot(map_robinson)
#national parks service images
upperMap <- openmap(c(70,-179),
c(10,50),zoom=2,type='nps')
#Lambert Conic Conformal
map_llc <- openproj(upperMap, projection=
"+proj=lcc +lat_1=33 +lat_2=45 +lat_0=39 +lon_0=-96")
plot(map_llc,removeMargin=TRUE)
#add choropleth
library(sp)
data(states)
st_llc <- spTransform(states,CRS("+proj=lcc +lat_1=33 +lat_2=45 +lat_0=39 +lon_0=-96"))
plot(st_llc,add=T,col=heat.colors(48,.4)[slot(st_llc,"data")[["ORDER_ADM"]]])
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.