Learn R Programming

oce (version 0.9-14)

mapImage: Plot an image on a existing map

Description

Plot an image on an existing map

Usage

mapImage(longitude, latitude, z, zlim, zclip=FALSE,
         breaks, col, colormap, border=NA,
         lwd=par("lwd"), lty=par("lty"),
         filledContour=FALSE, missingColor=NA, debug=getOption("oceDebug"))

Arguments

longitude
longitudes of grid lines
latitude
latitudes of grid lines
z
matrix for image
zlim
limit for z (colour)
zclip
logical, indicating whether to clip the colours to those corresponding to zlim, if the latter is provided. Clipped regions will be coloured with missingColor.
breaks
the z values for breaks in the colour scheme. If this is of length 1, the value indicates the desired number of breaks, which is supplied to pretty, in determining clean break points.
col
either a vector of colours corresponding to the breaks, of length 1 plus the number of breaks, or a function specifying colours, e.g. oceColorsJet for a rainbow.
colormap
optional colormap, as created by colormap. If provided, this takes precedence over breaks, code{col} and missingColor.
border
colour used for borders of patches (passed to polygon); the default NA means no border.
lwd
line width, used if borders are drawn
lty
line type, used if borders are drawn
filledContour
boolean value indicating whether to use filled contours to plot the image. This is ignored at present.
missingColor
a color to be used to indicate missing data, or NA to skip the drawing of such regions (which will retain whatever material has already been drawn at the regions).
debug
a flag that turns on debugging. Set to 1 to get a moderate amount of debugging information, or to 2 to get more. (Temporary note: setting this to 99 forces the use of a drawing method that draws polygons one by one, which is possi

Details

Adds an image to an existing map, by analogy to image.

See Also

See mapPlot for general information on plotting maps, including other functions.

Examples

Run this code
library(oce)
data(coastlineWorld)
mapPlot(coastlineWorld, type='l',
longitudelim=c(-70,-50), latitudelim=c(40,50),
proj="polyconic", orientation=c(90, -60,0), grid=TRUE)
data(topoWorld)
mapImage(topoWorld, col=oceColorsGebco)
mapMeridians(10, lty='dotted', col='darkgray')
mapZones(10, lty='dotted', col='darkgray')
mapLines(coastlineWorld)

## Northern polar region, with colour-coded bathymetry
drawPalette(c(-5000,0), zlim=c(-5000, 0), col=oceColorsJet)
mapPlot(coastlineWorld, type='l',
longitudelim=c(-180,180), latitudelim=c(60,120),
proj="stereographic", grid=TRUE)
data(topoWorld)
mapImage(topoWorld, zlim=c(-5000, 0), col=oceColorsJet)
mapMeridians()
mapZones()
mapLines(coastlineWorld[['longitude']], coastlineWorld[['latitude']])

# Levitus SST (requires dataset from http://www.esrl.noaa.gov)
con <- open.ncdf("/data/oar/levitus/temperature_annual_1deg.nc")
##con <- open.ncdf("/data/oar/levitus/temperature_annual_5deg.nc")
lon <- get.var.ncdf(con, "lon")
lat <- get.var.ncdf(con, "lat")
SST <- get.var.ncdf(con, "t_an")[,,1]
##SST <- get.var.ncdf(con, "t_mn")[,,1]
par(mar=rep(1, 4))
Tlim <- c(-2, 30)
drawPalette(Tlim, col=oceColorsJet)
mapPlot(coastlineWorld, projection='mollweide', grid=FALSE)
mapImage(lon, lat, SST, col=oceColorsJet, zlim=Tlim, debug=99)
mapPolygon(coastlineWorld, col='gray')

Run the code above in your browser using DataLab