Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

makeTopography

Make Topography Data from Online Source


Description

Make topography data suitable for the 'graphics::contour' and 'grDevices::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 Topex acquisition form. The function 'utils::read.table' will import dowloaded ASCII files into R, 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 'graphics::contour' and 'grDevices::contourLines' expect data conforming to this list format.

Author(s)

Nicholas M. Boers, Associate Professor – Computer Science
MacEwan University, Edmonton AB

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

See Also

In package graphics:
contour
In package grDevices:
contourLines
In package PBSmapping:
convCP

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)
})

PBSmapping

Mapping Fisheries Data and Spatial Analysis Tools

v2.73.0
GPL (>= 2)
Authors
Jon T. Schnute [aut], Nicholas Boers [aut], Rowan Haigh [aut, cre], Alex Couture-Beil [ctb], Denis Chabot [ctb], Chris Grandin [ctb], Angus Johnson [ctb], Paul Wessel [ctb], Franklin Antonio [ctb], Nicholas J. Lewin-Koh [ctb], Roger Bivand [ctb]
Initial release
2021-01-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.