sample.echogram {echogram} | R Documentation |
Select and sample data values from an echogram
Description
This function allows to select individual pixels from an echogram and returns the Sv value, ping time and depth of the sampled pixel.
Usage
sample.echogram(echogram, plot = TRUE, coords = NULL, col = "black")
Arguments
echogram |
an object of |
plot |
logical. If |
coords |
(x, y) coordinates (in plot units) of the desired samples. They could result from previous sampling of another frequency. |
col |
color for the sampled points pixels. |
Details
The selection of pixels to sample can be done by clicking on the echogram or by passing the coordinates of the desired pixels to the function. The coordinates should be in plot units, and therefore, these typically come from a previous selection by clicking on another frequency's echogram (see examples).
sample.echogram
makes use of locator
function, and therefore it only works in devices supported by the latter, such as X11
, windows
and quartz
.
Value
A data frame with seven variables:
id |
pixel id. |
x |
x coordinate in plot units. |
y |
y coordinate in plot units. |
d |
distance in plot units from the selected location to a valid pixel. |
pingTime |
time of sampled ping. |
depth |
depth of the sample. |
Sv |
Sv value. |
Author(s)
Héctor Villalobos
Examples
# import 38 and 120 kHz data from an HAC file
hacfile <- system.file("hac", "D20150510-T202500.hac", package = "echogram")
echo2.038 <- read.echogram(hacfile, channel = 1)
echo2.120 <- read.echogram(hacfile, channel = 2)
# plot 38 kHz echogram
echogram(echo2.038)
## Not run:
# select points coordinates with the mouse
# click to select several locations and escape when done
pts038 <- sample.echogram(echo2.038)
pts038
# plot 120 kHz echogram
echogram(echo2.120)
# use the points previously selected for 38 kHz
pts120 <- sample.echogram(echo2.120, coords = pts038[ , 2:3])
pts120
## End(Not run)