get.depth | R Documentation |
Outputs depth information based on points selected by clicking on a map
get.depth(mat, x, y=NULL, locator=TRUE, distance=FALSE, ...)
mat |
Bathymetric data matrix of class |
x |
Either a list of two elements (numeric vectors of longitude and latitude), a 2-column matrix or data.frame of longitudes and latitudes, or a numeric vector of longitudes. |
y |
Either |
locator |
Logical. Whether to choose data points interactively with a map or not. If |
distance |
whether to compute the haversine distance (in km) from the first data point on (default is |
... |
Further arguments to be passed to |
get.depth
allows the user to get depth data by clicking on a map created with plot.bathy
or by providing coordinates of points of interest. This function uses the locator
function (graphics
package); after creating a map with plot.bathy
, the user can click on the map once or several times (if locator=TRUE
), press the Escape button, and get the depth of those locations in a three-coumn data.frame (longitude, latitude and depth). Alternatively, when locator=FALSE
, the user can submit a list of longitudes and latitudes, a two-column matrix or data.frame of longitudes and latitudes (as input for x
), or one vector of longitudes (x
) and one vector of latitudes (y
). The non-interactive mode is well suited to get depth information for each point provided by GPS tracking devices. While get.transect
gets every single depth value available in the bathymetric matrix between two points along a user-defined transect, get.depth
only provides depth data for the specific points provided as input by the user.
A data.frame with at least, longitude, latitude and depth with one line for each point of interest. If distance=TRUE
, a fourth column containing the kilometric distance from the first point is added.
Benoit Simon-Bouhet and Eric Pante
path.profile
, get.transect
, read.bathy
, summary.bathy
, subsetBathy
, nw.atlantic
# load NW Atlantic data and convert to class bathy
data(nw.atlantic)
atl <- as.bathy(nw.atlantic)
# create vectors of latitude and longitude
lon <- c(-70, -65, -63, -55)
lat <- c(33, 35, 40, 37)
# a simple example
plot(atl, lwd=.5)
points(lon,lat,pch=19,col=2)
# Use get.depth to get the depth for each point
get.depth(atl, x=lon, y=lat, locator=FALSE)
# alternativeley once the map is plotted, use the iteractive mode:
## Not run:
get.depth(atl, locator=TRUE, pch=19, col=3)
## End(Not run)
# click several times and press Escape
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.