Plot an image on an existing map that was created with mapPlot()
.
(See example 4 for a way to start with a blank map.)
mapImage( longitude, latitude, z, zlim, zclip = FALSE, breaks, col, colormap, border = NA, lwd = par("lwd"), lty = par("lty"), missingColor = NA, filledContour = FALSE, gridder = "binMean2D", debug = getOption("oceDebug") )
longitude  numeric vector of longitudes corresponding to 

latitude  numeric vector of latitudes corresponding to 
z  numeric matrix to be represented as an image. 
zlim  limit for z (color). 
zclip  A logical value, 
breaks  The z values for breaks in the color scheme. If this is of
length 1, the value indicates the desired number of breaks, which is
supplied to 
col  Either a vector of colors corresponding to the breaks, of length
1 plus the number of breaks, or a function specifying colors,
e.g. 
colormap  optional colormap, as created by 
border  Color used for borders of patches (passed to

lwd  line width, used if borders are drawn. 
lty  line type, used if borders are drawn. 
missingColor  a color to be used to indicate missing data, or

filledContour  either a logical value indicating whether to use
filled contours to plot the image, or a numerical value indicating the
resampling rate to be used in interpolating from lonlat coordinates to
xy coordinates. See “Details” for how this interacts with

gridder  Name of gridding function used if 
debug  A flag that turns on debugging. Set to 1 to get a moderate amount of debugging information, or to 2 to get more. 
The data are on a regular grid in lonlat space, but not in the projected
xy space. This means that image()
cannot be used. Instead,
there are two approaches, depending on the value of filledContour
.
If filledContour
is FALSE
, the image pixels'' are with [polygon()], which can be prohibitively slow for fine grids. However, if `filledContour` is `TRUE` or a numerical value, then the
pixels'' are remapped into a regular grid and then displayed with
.filled.contour()
. The remapping starts by converting the
regular lonlat grid to an irregular xy grid using
lonlat2map()
. This irregular grid is then interpolated onto a
regular xy grid with binMean2D()
or with
akima::interp()
from the akima
package, as determined by
the gridder
argument. If filledContour
is TRUE
, the
dimensions of the regular xy grid is the same as that of the original
lonlat grid; otherwise, the number of rows and columns are multiplied by
the numerical value of filledContour
, e.g. the value 2 means to make
the grid twice as fine.
Filling contours can produce aestheticallypleasing results, but the method involves interpolation, so the data are not represented exactly and analysts are advised to compare the results from the two methods (and perhaps various grid refinement values) to guard against misinterpretation.
If a png()
device is to be used, it is advised to supply
arguments type="cairo"
and antialias="none"
; see reference 1.
A map must first have been created with mapPlot()
.
Other functions related to maps:
formatPosition()
,
lonlat2map()
,
lonlat2utm()
,
map2lonlat()
,
mapArrows()
,
mapAxis()
,
mapContour()
,
mapCoordinateSystem()
,
mapDirectionField()
,
mapGrid()
,
mapLines()
,
mapLocator()
,
mapLongitudeLatitudeXY()
,
mapPlot()
,
mapPoints()
,
mapPolygon()
,
mapScalebar()
,
mapText()
,
mapTissot()
,
oceCRS()
,
shiftLongitude()
,
usrLonLat()
,
utm2lonlat()
Dan Kelley
if (FALSE) { library(oce) data(coastlineWorld) data(topoWorld) ## Northern polar region, with colorcoded bathymetry par(mfrow=c(1,1), mar=c(2,2,1,1)) cm < colormap(zlim=c(5000, 0), col=oceColorsGebco) drawPalette(colormap=cm) mapPlot(coastlineWorld, projection="+proj=stere +lat_0=90", longitudelim=c(180,180), latitudelim=c(70,110)) mapImage(topoWorld, colormap=cm) mapGrid(15, 15, polarCircle=1, col=gray(0.2)) mapPolygon(coastlineWorld[['longitude']], coastlineWorld[['latitude']], col="tan") }