library(oce)
## (a) 1D: salinity profile with median and quartile 1 and 3
data(ctd)
p <- ctd[["pressure"]]
S <- ctd[["salinity"]]
q1 <- binApply1D(p, S, pretty(p, 30), function(x) quantile(x, 1/4))
q3 <- binApply1D(p, S, pretty(p, 30), function(x) quantile(x, 3/4))
plotProfile(ctd, "salinity", col='gray', type='n')
polygon(c(q1$result, rev(q3$result)),
c(q1$xmids, rev(q1$xmids)), col='gray')
points(S, p, pch=20)
## This requires the rgdal package to be installed
## (b) 2D: secchi depths in lat and lon bins
if (require(ocedata)) {
data(secchi, package="ocedata")
col <- rev(oce.colorsJet(100))[rescale(secchi$depth,
xlow=0, xhigh=20,
rlow=1, rhigh=100)]
zlim <- c(0, 20)
breaksPalette <- seq(min(zlim), max(zlim), 1)
colPalette <- rev(oce.colorsJet(length(breaksPalette)-1))
drawPalette(zlim, "Secchi Depth", breaksPalette, colPalette)
data(coastlineWorld)
mapPlot(coastlineWorld, longitudelim=c(-5,20), latitudelim=c(50,66),
grid=5, fill='gray', projection="+proj=lcc +lat_1=50 +lat_2=65")
bc <- binApply2D(secchi$longitude, secchi$latitude,
pretty(secchi$longitude, 80),
pretty(secchi$latitude, 40),
f=secchi$depth, FUN=mean)
mapImage(bc$xmids, bc$ymids, bc$result, zlim=zlim, col=colPalette)
mapPolygon(coastlineWorld, col='gray')
}
Run the code above in your browser using DataLab