Title: | Sequential Clustering Algorithm for Location Data |
---|---|
Description: | Applies sequential clustering algorithm to animal location data based on user-defined parameters. Plots interactive cluster maps and provides a summary dataframe with attributes for each cluster commonly used as covariates in subsequent modeling efforts. Additional functions provide individual keyhole markup language plots for quick assessment, and export of global positioning system exchange format files for navigation purposes. Methods can be found at <doi:10.1111/2041-210X.13572>. |
Authors: | Clapp, J. G. |
Maintainer: | Justin Clapp <[email protected]> |
License: | GPL-3 |
Version: | 1.4.0 |
Built: | 2024-11-12 06:44:56 UTC |
Source: | CRAN |
label plots
addTitle( object, text, color = "black", fontSize = "20px", fontFamily = "Sans", leftPosition = 50, topPosition = 2 )
addTitle( object, text, color = "black", fontSize = "20px", fontFamily = "Sans", leftPosition = 50, topPosition = 2 )
object |
leaflet plot |
text |
text |
color |
text color |
fontSize |
font size |
fontFamily |
font |
leftPosition |
left position |
topPosition |
top position |
title on plots
Uses results from 'GPSeq_clus" to export .gpx file from specified AID and vector of desired cluster numbers for navigation during field site investigations.
exp_clus_gpx(AID, cn = "all", locs, cs, centroid_calc = "mean", dir = NULL)
exp_clus_gpx(AID, cn = "all", locs, cs, centroid_calc = "mean", dir = NULL)
AID |
Desired AID from sequential cluster output |
cn |
Numeric vector of desired cluster numbers to include in .gpx output, default is "all" |
locs |
Location dataframe output from GPSeq_clus() |
cs |
Cluster summary output from GPSeq_clus() |
centroid_calc |
'mean' (default) or 'median' centroid plot |
dir |
File path to save output |
.gpx file
exp_clus_gpx(AID = "ML1605M", cn = 4, locs = GPSeq_clus(dat = ML_ex_dat[1:50,], search_radius_m = 200, window_days = 6, clus_min_locs = 3, show_plots = c(FALSE, "mean"))[[1]], cs = GPSeq_clus(dat = ML_ex_dat[1:50,], search_radius_m = 200, window_days = 6, clus_min_locs = 3, show_plots = c(FALSE, "mean"))[[2]], dir= tempdir() )
exp_clus_gpx(AID = "ML1605M", cn = 4, locs = GPSeq_clus(dat = ML_ex_dat[1:50,], search_radius_m = 200, window_days = 6, clus_min_locs = 3, show_plots = c(FALSE, "mean"))[[1]], cs = GPSeq_clus(dat = ML_ex_dat[1:50,], search_radius_m = 200, window_days = 6, clus_min_locs = 3, show_plots = c(FALSE, "mean"))[[2]], dir= tempdir() )
Applies sequential clustering algorithm to location data based on user-defined parameters and appends results to the dataframe. Provides a summary dataframe with attributes for each cluster commonly used as covariates in subsequent modeling efforts. Plots interactive cluster maps.
GPSeq_clus( dat, search_radius_m, window_days, clus_min_locs = 2, centroid_calc = "mean", show_plots = c(TRUE, "mean"), scale_plot_clus = TRUE, store_plots = FALSE, season_breaks_jul = NA, daylight_hrs = NA, prbar = TRUE )
GPSeq_clus( dat, search_radius_m, window_days, clus_min_locs = 2, centroid_calc = "mean", show_plots = c(TRUE, "mean"), scale_plot_clus = TRUE, store_plots = FALSE, season_breaks_jul = NA, daylight_hrs = NA, prbar = TRUE )
dat |
Any dataframe including single or multiple animal location datasets that includes:
|
search_radius_m |
Search radius (meters) from cluster centroid when building clusters. |
window_days |
Temporal window (days) to search for new locations from the most recent location in a cluster |
clus_min_locs |
Minimum number of locations required to form a cluster. Default is 2. |
centroid_calc |
Method for recalculating centroids when actively building clusters - e.g., "median" or "mean" (default). Not to be confused with plotting the "mean" or "median" centroid once a cluster has been built. |
show_plots |
Vector of TRUE/FALSE for plotting followed by plotting argument for the "median" or "mean" centroid - e.g., c(TRUE, "mean") (default) |
scale_plot_clus |
When plotting, scale cluster markers based on number of locations (TRUE/FALSE). |
store_plots |
When plotting, also assign map outputs to global environment (TRUE/FALSE). |
season_breaks_jul |
Ascending numeric vector of julian days (0-365) used to classify by season/parturition/hunting seasons etc. e.g., c(121, 274, 305) result may be: 1 Nov - 30 Apr (winter = 0), 1 May - 31 Aug (summer = 1), 1 Oct - 31 Oct (hunting season = 2) |
daylight_hrs |
Manually set start and stop hours (0-24) to classify day and night locations. - e.g. c(6,18) would classify 6AM - 6PM as daylight hrs. NA (default) uses 'suncalc' package to convert cluster location and time to be classified based on specific specific sunrise and sunset times. |
prbar |
Show progress bars (TRUE/FALSE). |
Returns a list containing two dataframes. The first contains the original location dataframe with "clus_ID" column assigning each row a cluster ID if applicable. The second dataframe in the list contains a summary of sequential clusters and common cluster attributes (descriptions below) for subsequent modeling. If 'show_plots' argument is active, returns interactive maps of locations and clusters by animal.
Animal identification
Sequential cluster ID number
Timestamp of first location in cluster
Timestamp of last location in cluster
"Closed" if the time window (window_days) has expired for the cluster according to users Sys.time() output. These clusters are therefore solidified and should not change if appending new location data. "Open" if the time window remains open at the time the function was run. "Open" clusters have the ability to shift sequence, combine with other clusters, emerge as a new cluster, etc. This attribute becomes relevant when appending new satellite data to the location dataframe, and may serve as an index of whether an animal continues to actively visit the cluster site within the time window.
Geometic centroid longitude value calculated using the mean
Geometic centroid latitude value calculated using the mean
Geometic centroid longitude value calculated using the median
Geometic centroid latitude value calculated using the median
Hours from the first to last locations of the cluster
Number of locations within the cluster
Number of visits/revisits to the cluster based on the number of times locations fall outside the search radius and return to add locations to the cluster
Fix rate success during the duration of the cluster
Adjusted number of cluster locations accounting for missed fixes (number cluster locations / fix success of cluster duration)
Fidelity to the cluster during cluster duration (number locations on cluster - number locations off cluster)
Maximum location distance (meters) from centroid during cluster duration for all locations
Maximum location distance (meters) from centroid during cluster duration for cluster-attributed locations
Mean distance from all cluster locations to centroid
Number of unique 24 hr periods during the cluster duration that hold at least one cluster location
Binary output for cluster duration (0 == less or equal to 24hr, 1 == greater than 24hr)
Nominal attribute for user defined seasons based on 'season_breaks_jul' argument
Number of night cluster locations based on 'daylight_hrs' argument
Proportion of night cluster locations
GPSeq_clus(dat = ML_ex_dat[1:50,], search_radius_m = 200, window_days = 6, clus_min_locs = 3, show_plots = c(FALSE, "mean")) GPSeq_clus(dat = ML_ex_dat, search_radius_m = 50, window_days = 2.5, clus_min_locs = 12, centroid_calc = "median", show_plots = c(TRUE, "median"), scale_plot_clus = FALSE, season_breaks_jul = c(120, 240, 300), daylight_hrs = c(8, 16), prbar=FALSE)
GPSeq_clus(dat = ML_ex_dat[1:50,], search_radius_m = 200, window_days = 6, clus_min_locs = 3, show_plots = c(FALSE, "mean")) GPSeq_clus(dat = ML_ex_dat, search_radius_m = 50, window_days = 2.5, clus_min_locs = 12, centroid_calc = "median", show_plots = c(TRUE, "median"), scale_plot_clus = FALSE, season_breaks_jul = c(120, 240, 300), daylight_hrs = c(8, 16), prbar=FALSE)
Uses results from 'GPSeq_clus" to plot individual cluster .kmls
ind_clus_kml( AID, cn, locs, cs, centroid_calc = "mean", overwrite = TRUE, dir = NULL )
ind_clus_kml( AID, cn, locs, cs, centroid_calc = "mean", overwrite = TRUE, dir = NULL )
AID |
Desired AID from sequential cluster output |
cn |
Desired cluster number |
locs |
Location dataframe output from GPSeq_clus() |
cs |
Cluster summary output from GPSeq_clus() |
centroid_calc |
'mean' (default) or 'median' centroid plot |
overwrite |
TRUE (default) labels output as "ind.kml" that overwrites with each run within tempdir(). FALSE saves outputs as "AID_cn" |
dir |
File path when saving output |
Opens the cluster locations and centroid .kml for assessment.
Julian Conversion
julian_conv(x)
julian_conv(x)
x |
vector of input dates |
vector of julian days
A dataframe
containing a subset of GPS location data from 2 male and 1 female mountain lions used
for testing and running sequential cluster function examples.Example data provided by Wyoming Game and Fish Department, 2020.
ML_ex_dat
ML_ex_dat
A dataframe
containing 4 columns:
animal identification
location timestamp in POSIXct format
latitude coordinates
longitude coordinates
arrange columns
moveMe(data, tomove, where = "last", ba = NULL)
moveMe(data, tomove, where = "last", ba = NULL)
data |
input dataframe |
tomove |
which column(s) to move |
where |
where to move them - e.g. "before", "after", "first", "last" |
ba |
?? |
Dataframe with new column order