mapContour | R Documentation |
Draw contour lines to an existing map, using mapLines()
.
Note that label placement in mapContour
is handled differently
than in contour()
.
mapContour(
longitude,
latitude,
z,
nlevels = 10,
levels = pretty(range(z, na.rm = TRUE), nlevels),
labcex = 0.6,
drawlabels = TRUE,
underlay = "erase",
col = par("fg"),
lty = par("lty"),
lwd = par("lwd"),
debug = getOption("oceDebug")
)
longitude |
numeric vector of longitudes of points to be
plotted, or an object of class |
latitude |
numeric vector of latitudes of points to be plotted. |
z |
matrix to be contoured. The number of rows and columns in
|
nlevels |
number of contour levels, if and only if |
levels |
vector of contour levels. |
labcex |
|
drawlabels |
logical value or vector indicating whether to
draw contour labels. If the length of |
underlay |
character value relating to handling labels. If
this equals |
col |
colour of the contour line, as for |
lty |
type of the contour line, as for |
lwd |
width of the contour line, as for |
debug |
an integer specifying whether debugging information is
to be printed during the processing. This is a general parameter that
is used by many |
library(oce) data(coastlineWorld) if (requireNamespace("ocedata", quietly=TRUE)) { data(levitus, package = "ocedata") par(mar = rep(1, 4)) mapPlot(coastlineWorld, projection = "+proj=robin", col = "lightgray") mapContour(levitus$longitude, levitus$latitude, levitus$SST) }
Suppose a map has been plotted using longitudes that are bound between -180
and 180. To overlay contours defined with longitude bound between 0 and 360
(as for the built-in coastlineWorld
dataset), try Clark Richards' method
(https://github.com/dankelley/oce/issues/2217, as below.
# Start with z=z(lon,lat), with lon bound by 0 and 360 z2 <- rbind(z[lon > 180, ], z[lon <= 180, ]) lon2 <- lon + 180 mapContour(lon2, lat, z2)
Dan Kelley
A map must first have been created with mapPlot()
.
Other functions related to maps:
formatPosition()
,
lonlat2map()
,
lonlat2utm()
,
map2lonlat()
,
mapArrows()
,
mapAxis()
,
mapCoordinateSystem()
,
mapDirectionField()
,
mapGrid()
,
mapImage()
,
mapLines()
,
mapLocator()
,
mapLongitudeLatitudeXY()
,
mapPlot()
,
mapPoints()
,
mapPolygon()
,
mapScalebar()
,
mapText()
,
mapTissot()
,
oceCRS()
,
oceProject()
,
shiftLongitude()
,
usrLonLat()
,
utm2lonlat()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.