Learn R Programming

marmap (version 1.0.10)

get.sample: Get sample data by clicking on a map

Description

Outputs sample information based on points selected by clicking on a map

Usage

get.sample(mat, sample, col.lon, col.lat, ...)

Value

a dataframe of the elements of sample present within the area selected

Arguments

mat

bathymetric data matrix of class bathy, imported using read.bathy (no default)

sample

data.frame containing sampling information (at least longitude and latitude) (no default)

col.lon

column number of data frame sample containing longitude information (no default)

col.lat

column number of data frame sample containing latitude information (no default)

...

further arguments to be passed to rect for drawing a box around the selected area

Author

Eric Pante

Warning

clicking once or more than twice on the map will return a warning message: "Please choose two points from the map"

Details

get.sample allows the user to get sample data by clicking on a map created with plot.bathy. This function uses the locator function (graphics package). After creating a map with plot.bathy, the user can click twice on the map to delimit an area (for example, lower left and upper right corners of a rectangular area of interest), and get a dataframe corresponding to the sample points present within the selected area.

See Also

read.bathy, summary.bathy, nw.atlantic, metallo

Examples

Run this code
if (FALSE) {
# load metallo sampling data and add a third field containing a specimen ID
data(metallo)
metallo$id <- factor(paste("Metallo",1:38))

# load NW Atlantic data, convert to class bathy, and plot
data(nw.atlantic)
atl <- as.bathy(nw.atlantic)
plot(atl, deep=-8000, shallow=0, step=1000, col="grey")

# once the map is plotted, use get.sample to get sampling info!
get.sample(atl, metallo, 1, 2)
# click twice
}

Run the code above in your browser using DataLab