makeTopography {PBSmapping}R Documentation

Make Topography Data from Online Source

Description

Make topography data suitable for the contour and contourLines functions using freely available global seafloor topography data.

Usage

makeTopography (dat, digits=2, func=NULL)

Arguments

dat

data.frame – data with three optionally-named columns: x, y, and z. The columns must appear in that order.

digits

numeric – integer indicating the precision to be used by the function round on (x,y) values.

func

function – to summarize z if (x,y) points are duplicated. Defaults to mean() if no function is specified.

Details

Suitable data can be obtained through the acquisition form at:
http://topex.ucsd.edu/cgi-bin/get_data.cgi.
The function read.table will import dowloaded ASCII files into R/S, creating objects suitable for the argument dat in makeTopography.

When creating data for regions with longitude values spanning -180 degrees to 0 degrees, consider subtracting 360 from the result's longitude coordinates (x).

When creating bathymetry data, consider negating the result's elevations (z) to give depths positive values.

Combinations of (x,y) do not need to be complete (z[x,y]=NA) or unique (z[x,y] = func(z[x,y])).

Value

List with elements x, y, and z. Elements x and y are vectors, while z is a matrix with rownames x and colnames y. The functions contour and contourLines expect data conforming to this list format.

Author(s)

Rowan Haigh, Program Head – Offshore Rockfish
Pacific Biological Station (PBS), Fisheries & Oceans Canada (DFO), Nanaimo BC
opus locus: Institute of Ocean Sciences (IOS), Sidney BC
Last modified Rd: 2018-09-10

See Also

contour in graphics,
contourLines in grDevices, and
convCP in PBSmapping.

Examples

local(envir=.PBSmapEnv,expr={
  oldpar = par(no.readonly=TRUE)
  #--- Example 1: Sample data frame and conversion.
  file <- data.frame(X=c(1,1,2,2),Y=c(3,4,3,4),Z=c(5,6,7,8))
  print(makeTopography(file))

  #--- Example 2: Aleutian Islands bathymetry
  isob <- c(100,500,1000,2500,5000)
  icol <- rgb(0,0,seq(255,100,len=length(isob)),max=255)
  afile <- paste(system.file(package="PBSmapping"),
    "/Extra/aleutian.txt",sep="")
  aleutian <- read.table(afile, header=FALSE, col.names=c("x","y","z"))
  aleutian$x <- aleutian$x - 360
  aleutian$z <- -aleutian$z
  alBathy <- makeTopography(aleutian)
  alCL <- contourLines(alBathy,levels=isob)
  alCP <- convCP(alCL)
  alPoly <- alCP$PolySet
  attr(alPoly,"projection") <- "LL"
  plotMap(alPoly, type="n", cex.axis=1.2, cex.lab=1.5)
  addLines(alPoly,col=icol)
  data(nepacLL,envir=.PBSmapEnv)
  addPolys(nepacLL,col="gold")
  legend(x="topleft",bty="n",col=icol,lwd=2,legend=as.character(isob))
  par(oldpar)
})

[Package PBSmapping version 2.72.1 Index]