
This function allows to select individual pixels from an echogram and returns the Sv value, ping time and depth of the sampled pixel.
sample.echogram(echogram, plot = TRUE, coords = NULL, col = "black")
A data frame with seven variables:
pixel id.
x coordinate in plot units.
y coordinate in plot units.
distance in plot units from the selected location to a valid pixel.
time of sampled ping.
depth of the sample.
Sv value.
an object of class
``echogram'' as returned by read.echogram
.
logical. If TRUE
(the default), the echogram to be sampled is plotted.
(x, y) coordinates (in plot units) of the desired samples. They could result from previous sampling of another frequency.
color for the sampled points pixels.
Héctor Villalobos
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
.
# 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)
if (FALSE) {
# 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
}
Run the code above in your browser using DataLab