detection_bubble_plot: Plot number of tagged animals or detections on a map

View source: R/vis-detection_bubble_plot.r

detection_bubble_plotR Documentation

Plot number of tagged animals or detections on a map

Description

Make bubble plots showing the number of fish detected across a defined set of receiver locations.

Usage

detection_bubble_plot(det, location_col = "glatos_array",
  receiver_locs = NULL, map = NULL, out_file = NULL,
  background_ylim = c(41.3, 49), background_xlim = c(-92.45, -75.87),
  symbol_radius = 1, col_grad = c("white", "red"), scale_loc = NULL)

Arguments

det

A glatos_detections object (e.g., produced by read_glatos_detections).

OR a data frame containing detection data with four columns described below and one column containing a location grouping variable, whose name is specified by location_col (see below).

The following four columns must appear in det, except deploy_lat and deploy_lon are not needed if receiver_locs is specified:

animal_id

Individual animal identifier; character.

detection_timestamp_utc

Timestamps for the detections (MUST be of class 'POSIXct').

deploy_lat

Latitude of receiver deployment in decimal degrees, NAD83.

deploy_long

Longitude of receiver deployment in decimal degrees, NAD83.

location_col

A character string indicating the column name in det (and receiver_locs if specified) that will be used as the location grouping variable (e.g. "glatos_array"), in quotes.

receiver_locs

An optional data frame containing receiver data with the two columns ('deploy_lat', 'deploy_long') described below and one column containing a location grouping variable, whose name is specified by location_col (see above). The following two columns must appear in receiver_locs:

  • deploy_lat Latitude of receiver deployment in decimal degrees, NAD83.

  • deploy_long Longitude of receiver deployment in decimal degrees, NAD83.

map

An optional SpatialPolygonsDataFrame or other spatial object that can by plotted with using plot to be included as the background for the plot. If NULL, then the example Great Lakes polygon object (data(greatLakesPoly)) will be used.

out_file

An optional character string with the name (including extension) of output file created. File extension will determine type of file written. For example, "BubblePlot.png" will write a png file to the working directory. If NULL (default) then the plot will be printed to the default plot device. Supported extensions: png, jpeg, bmp, and tiff.

background_ylim

A two-element numeric vector that defines minimum and maximum extents of the viewable plot area along the y-axis (i.e., longitude).

background_xlim

A two-element numeric vector that defines minimum and maximum extents of the viewable plot area along the x-axis (i.e., latitude).

symbol_radius

Radius of each "bubble" on the plot in units of percent of x-axis scale. Default value = 1 (i.e., 1 percent of x-axis).

col_grad

A two-element character vector indicating the start and end colors of the gradient scale used to color-code "bubbles".

scale_loc

An optional 4-element numeric vector, to be passed to plotrix::color.legend, indicating the plotting location of the legend in the same units as map. Elements in the vector are the lower left and upper right coordinates of the rectangle of colors (i.e., c(xleft, ybottom, xright, ytop)). If scale_loc = NULL (default), the legend is plotted along the left edge of the plot.

Details

Data are summarized using summarize_detections.

If receiver_locs is specified (not NULL) then the plot will show all receivers in receiver_locs including any that detected none of the transmitters in det. Although this is helpful to view locations where fish were not detected, the user will usually want to take care to include only receivers that were in the water during the period of interest. If you are using a glatos receiver locations file to specify location for plotting, you will likely want to filter the receiver data by depoyment and receovery dates to exclude deployments that occured outside of the period of interest.

"col_grad" is used in a call to colorRampPalette, which will accept a vector containing any two colors return by colors as character strings.

Value

A data frame produced by glatos::summarize_detections(det, location_col = location_col, receiver_locs = receiver_locs, summ_type = "location")

If not out_file is specified, then an image is printed to the default plot device. If out_file is specified, then an image of specified type is written to out_file.

Author(s)

T. R. Binder, edited by A. Dini

See Also

summarize_detections

Examples


#get path to example detection file
det_file <- system.file("extdata", "walleye_detections.csv",
  package = "glatos")
det <- read_glatos_detections(det_file)

#call with defaults
detection_bubble_plot(det)

#change symbol size and color
detection_bubble_plot(det, symbol_radius = 2, col_grad = c("grey90", "grey10"))

#Add all receivers

# get path to example receiver file
rec_file <- system.file("extdata", "sample_receivers.csv",
  package = "glatos")
rec <- read_glatos_receivers(rec_file)

detection_bubble_plot(det, receiver_locs = rec)


#' #Subset receivers to include on receivers that were deployed during the
#' detection interval.

# get path to example receiver file
rec_file <- system.file("extdata", "sample_receivers.csv",
  package = "glatos")
rec <- read_glatos_receivers(rec_file)

first <- min(det$detection_timestamp_utc) # time of first detection
last <- max(det$detection_timestamp_utc) # time of last detection

# Subset receiver deployments oustide the detection period.
# !is.na(rec$recover_date_time) eliminates receivers that have been
# deployed but not yet recovered.
plot_rec <- rec[rec$deploy_date_time < last & 
                rec$recover_date_time > first & 
                !is.na(rec$recover_date_time),]

detection_bubble_plot(det, receiver_locs = plot_rec)



jsta/glatos documentation built on July 11, 2022, 7:01 a.m.