proc_dets: Combine detections with stations

Description Usage Arguments Details Value Functions See Also Examples

View source: R/s1_proc_inputs.R

Description

This function combines detections with stations to place detections in space.

Usage

1
2
3
proc_dets(det, sta, crs = 4326)

is.dets(x)

Arguments

det

A data.frame of detections. Format should match the object detections from acoustic (id, dt, rec_id).

sta

A data.frame of the stations where receivers were located for a period of time. Format should match the object stations from acoustic (sta_id, rec_id, dt_dep, dt_ret, x, y).

crs

Coordinate Reference System to use for the detections. Passed to sf::st_crs() to set CRS for sf object. Defaults to 4326, longitude/latitude on the WGS84 spheroid.

x

An object to check with is.dets().

Details

Uses sqldf to combine det with sta using rec_id where the date-time of the detection falls within the date-time of the station deployment.

It specifically excutes the following SQL SELECT query:

1
2
3
4
5
 SELECT id, sta.rec_id, sta_id, dt, lon, lat
 FROM det LEFT JOIN sta
 ON det.rec_id = sta.rec_id
     AND det.dt > sta.dt_dep
     AND det.dt < sta.dt_ret

The left join keeps all rows from the detections data.frame, inserting an NA if there is a detection not within one of the time intervals for a given receiver. The function subsequently removes any locations with NA in the x- or y-coordinate with a warning.

Value

Returns a data.frame of class dets of georeferenced detections. Object is also of class sf and contains column geometry.

Functions

See Also

acoustic for details on the formatting of the data.frames det and sta

Examples

1
2
3
4
5
#Load the example data set
data(acoustic)

#Process detections
proc.det <- proc_dets(det = acoustic$detections, sta = acoustic$stations)

bsmity13/ADePTR documentation built on Nov. 9, 2019, 12:43 a.m.