map.grid | 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: |
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 |
cex, col, lty, font |
passed to arguments to |
... |
additional arguments passed to |
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.
map
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.