plot_paths: Plot an object of class '*_paths'

Description Usage Arguments Details Functions Examples

View source: R/s5_interpolate_animate.R

Description

Plots the paths between locations for all individuals in an str_paths or an lc_paths object.

Usage

1
2
3
4
5
6
plot_paths(paths, path_palette = viridis::viridis, add = FALSE,
set_par = !add, use_ggplot = FALSE)

plot.str_paths(stps, ...)

plot.lc_paths(lcps, ...)

Arguments

paths

An object of class *_paths: either str_paths or lc_paths

path_palette

A function name that will generate a palette for each of the individuals tracked. Can be any function that will accept n as an argument.

add

TRUE or FALSE. Should the plot be added to an existing plot? Defaults to FALSE. Not applicable if use_ggplot = TRUE. User could, e.g., use this option to add this plot on top of map_dets().

set_par

TRUE or FALSE. Should the function change the graphical parameters or not? This should be FALSE if the user wishes to manually set the graphical parameters, e.g., so that they can still add to the plot manually after it is generated. Defaults to !add.

use_ggplot

TRUE or FALSE. Should the plot be made using ggplot2? Defaults to FALSE and uses base R plotting.

stps

An object of class str_paths to be passed from the generic plot() to plot_paths()

lcps

An object of class lc_paths to be passed from the generic plot() to plot_paths()

Details

Blah blah

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#Load sample data
data(acoustic)

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

#Calculate  COAs -- Note, using 6 hour COAs to reduce processing time
coas.6h <- coa_locs(proc.det, Delta_t = "6 hours")

#Initialize raster
r.cond <- init_raster(study_area = acoustic$study_area, res = 0.001)

#Create conductance raster
conduct <- raster_conduct(sa_rast = r.cond, impassable = acoustic$land)

#Create least-cost paths
lcps <- lc_paths(det_locs = coas.6h, conductance = conduct)

#Plot
plot_paths(lcps)

#Plot on top of detections
  #Note set_par = FALSE in both functions
  #Consider manually setting graphical parameters for this plot

map_dets(proc_det = proc.det, sta_crs = 4326,
  base_layers = list(acoustic$study_area, acoustic$land),
  base_cols = list("gray30", "wheat"), base_borders = list(NA, "seagreen"),
  xlim=c(-64.636, -64.604), ylim=c(17.770, 17.795),
  leg_pos = "topleft", sta_col = "blue", sta_bg = "orange",
  set_par = FALSE)

plot_paths(lcps, set_par = FALSE, add = TRUE)

#Plot with ggplot
plot_paths(lcps, use_ggplot = TRUE) +
  theme_bw() +
  geom_sf(data = acoustic$land)

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