map.grid {mapproj} | R Documentation |
Draws a grid on an existing map.
map.grid(lim,nx=9,ny=9,labels=TRUE,pretty=TRUE,cex,col,lty,font,...)
lim |
a vector of 4 numbers specifying
limits: c(lon.low, lon.high, lat.low, lat.high) .
lim can also be a list with a component named range , such
as the result of map , from which limits are taken.
|
nx,ny |
the desired number of equally-spaced longitude and latitude lines |
labels |
logical to indicate if grid lines should be labeled with longitude/latitude values. |
pretty |
If TRUE , grid lines will be placed at round numbers. |
cex |
|
col |
|
lty |
|
font |
|
... |
additional arguments passed to lines and
text , e.g. col to change the color of the grid and
lty to change the line type. |
Equally-spaced lines of constant longitude and lines of constant latitude are superimposed on the current map, using the current projection. These lines will appear curved under most projections, and give an idea of how the projection works.
library(maps) m <- map("usa",plot=FALSE) map("usa",project="albers",par=c(39,45)) map.grid(m) # get unprojected world limits m <- map('world',plot=FALSE) # center on NYC map('world',proj='azequalarea',orient=c(41,-74,0)) map.grid(m,col=2) points(mapproject(list(y=41,x=-74)),col=3,pch="x",cex=2) map('world',proj='orth',orient=c(41,-74,0)) map.grid(m,col=2,nx=6,ny=5,label=FALSE,lty=2) points(mapproject(list(y=41,x=-74)),col=3,pch="x",cex=2) # center on Auckland map('world',proj='orth',orient=c(-36.92,174.6,0)) map.grid(m,col=2,label=FALSE,lty=2) points(mapproject(list(y=-36.92,x=174.6)),col=3,pch="x",cex=2) m <- map('nz') # center on Auckland map('nz',proj='azequalarea',orient=c(-36.92,174.6,0)) points(mapproject(list(y=-36.92,x=174.6)),col=3,pch="x",cex=2) map.grid(m,col=2)