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

View source: R/get.sample.R

get.sampleR Documentation

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, ...)

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

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.

Value

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

Warning

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

Author(s)

Eric Pante

See Also

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

Examples

## Not run: 
# 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

## End(Not run)

marmap documentation built on March 31, 2023, 6:59 p.m.

Related to get.sample in marmap...