Title: | Estimating Geographic Space Available to Animals Based on Telemetry Data |
---|---|
Description: | Estimating geographic space available to animals based on telemetry data. |
Authors: | Ben Raymond [aut, cre], Simon Wotherspoon [aut], Ian Jonsen [aut], Ryan Reisinger [aut] |
Maintainer: | Ben Raymond <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.16.0 |
Built: | 2024-11-04 03:18:57 UTC |
Source: | https://github.com/AustralianAntarcticDivision/availability |
Estimating geographic space available to animals based on telemetry data
Ben Raymond [email protected], Simon Wotherspoon, Ryan Reisinger
Calculate distances in metres and bearing between successive points along track.
calc_distbearing(lonlat)
calc_distbearing(lonlat)
lonlat |
a 2-column matrix or dataframe with longitude and latitude of each point |
This is an internal function used by randomize_track
.
A dataframe with columns
lon |
the longitude of the randomized track |
lat |
the latitude of the randomized track |
A land mask based on the full ETOPO1 dataset
etopoMask( basename = "ETOPO1_Bed_c_geotiff", path = ".", tmp = path, land = FALSE )
etopoMask( basename = "ETOPO1_Bed_c_geotiff", path = ".", tmp = path, land = FALSE )
basename |
the name of the etopo geotiff (without file extension). |
path |
the path to a folder containing the etopo geotiff |
tmp |
the path to a writeable folder |
land |
the logical value to return for land. |
Generate a land mask function based on ETOPO1 topography. The etopo geotiff is not bundled with the package and must be downloaded from https://www.ngdc.noaa.gov/mgg/global/global.html.
When the mask is intially created, a native raster (grd, gri)
version of the geotiff is created in the directory tmp
,
which must be writable. This file can be deleted when the
computation is finished.
The land
argument determines whether the mask function
returns TRUE
or FALSE
for land. The mask is constant
and the tm
argument to the mask is ignored.
a logical indicating whether the point is land or sea.
Generate a land mask function based on the Global Self-consistent, Hierarchical, High-resolution Geography Database.
The mask is provided at two (approximate) spatial resolutions: 0.1 degree and 0.05 degrees. The latter requires significantly more memory.
The mask is constant and the tm
argument to the mask is ignored.
gshhsMask(res = 0.1, latmin = -90, latmax = 90) landmask_init(res = 0.1, latmin = -90, latmax = 90)
gshhsMask(res = 0.1, latmin = -90, latmax = 90) landmask_init(res = 0.1, latmin = -90, latmax = 90)
res |
numeric: the spatial resolution of the mask, in degrees (either 0.1 or 0.05) |
function that returns a logical indicating whether the point is at sea (TRUE) or on land (FALSE)
Wessel P, Smith WHF (1996) A Global Self-consistent, Hierarchical, High-resolution Shoreline Database. J. Geophys. Res. 101: 8741-8743. https://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html
mask <- gshhsMask() ## initialize land mask function mask(0, c(100, -65)) ## test point lon,lat
mask <- gshhsMask() ## initialize land mask function mask(0, c(100, -65)) ## test point lon,lat
Three example animal tracks, from Reisinger et al. (2018)
data(ptt_data)
data(ptt_data)
A list containing three tracks collected using Argos PTT tags: DMS
from a sooty shearwater, SES
from an elephant seal, and AFS
from an Antarctic fur seal.
https://doi.org/10.1111/ddi.12702
Compute surrogate track by randomizing the steps of an observed track
randomize_track(lonlat, rotate = c(-pi, pi), reorder = FALSE)
randomize_track(lonlat, rotate = c(-pi, pi), reorder = FALSE)
lonlat |
a 2-column matrix or dataframe with longitude and latitude of each point |
rotate |
a 2-element numeric vector giving the lower and upper limits of the random rotation to apply to the randomized track |
reorder |
should the track steps be randomly reordered. |
Converts a track to a distance/bearing representation, and then reconstructs a new track by randomly perturbing the bearings of each increment, and otpionally, randomly reordering the increments.
A dataframe with columns
lon |
the longitude of the randomized track |
lat |
the latitude of the randomized track |
Simulate track from fitted vector autoregressive model
surrogate_arsimulate( arfit, n, startlonlat, fixed = NULL, endlonlat = NULL, do.test.land = TRUE, random.rotation = c(-pi, pi), verbose = 0, return.all.points = FALSE, intermediate.tries = 10, original = FALSE ) surrogate_arsimulate0( arfit, n, startlonlat, fixed = NULL, endlonlat = NULL, do.test.land = TRUE, random.rotation = c(-pi, pi), verbose = 0, return.all.points = FALSE, intermediate.tries = 10 )
surrogate_arsimulate( arfit, n, startlonlat, fixed = NULL, endlonlat = NULL, do.test.land = TRUE, random.rotation = c(-pi, pi), verbose = 0, return.all.points = FALSE, intermediate.tries = 10, original = FALSE ) surrogate_arsimulate0( arfit, n, startlonlat, fixed = NULL, endlonlat = NULL, do.test.land = TRUE, random.rotation = c(-pi, pi), verbose = 0, return.all.points = FALSE, intermediate.tries = 10 )
arfit |
fitted object of class "ar" as returned by
|
n |
number of points to simulate |
startlonlat |
2-element vector of starting longitude and latitude |
fixed |
a dataframe or matrix in which the first column is the index (from 1:n) of each fixed point, and the second and third columns give the associated longitude and latitude |
endlonlat |
a 2-element vector with ending longitude and
latitude. If NULL, no end constraint is imposed except for land
masking (if land masking is used). This is a simple way of
imposing a return-to-starting-location constraint; for more
complex constraints use the |
do.test.land |
a logical or function. If TRUE, use the included land mask to avoid land. Alternatively, a function can be passed that returns TRUE (point is okay, not on land) or FALSE (point is on land) for a given lon,lat. Note that land masking is ignored for fixed points. Note also that it is possible to create a sitation where tracks are difficult or impossible to simulate, because a fixed point is sufficiently far onto land that the track cannot reach it. |
random.rotation |
a 2-element vector giving the range of
the rotation to apply to the randomized track (values in
radians). use |
verbose |
an integer 0-3, if >0 spit out extra information which may be helpful if things don't work as expected. Larger numbers mean more output |
return.all.points |
if TRUE, return points that were proposed but rejected due to land masking (may be helpful for debugging). If TRUE, the returned data.frame will have an extra column named "valid" |
intermediate.tries |
when land-masking, try how many times to find a valid point at each step before giving up and starting again? Higher values may improve overall run-time, but too-high values may yield tracks that aren't a good representation of the fitted model |
original |
if |
Note that land masking uses a built-in land mask image, and it only covers the southern hemisphere. A future version will do something about this.
2 or 3 column dataframe with the longitude and latitude of simulated track points (and point validity, if return.all.points is TRUE)
Generate new tracks from a VAR(1)
surrogateAR( model, xs, ts = seq_len(nrow(xs)), fixed = rep(c(TRUE, FALSE, TRUE), c(1, nrow(xs) - 2, 1)), point.check = function(tm, pt) TRUE, random.rotation = c(-pi, pi), partial = FALSE )
surrogateAR( model, xs, ts = seq_len(nrow(xs)), fixed = rep(c(TRUE, FALSE, TRUE), c(1, nrow(xs) - 2, 1)), point.check = function(tm, pt) TRUE, random.rotation = c(-pi, pi), partial = FALSE )
model |
a model generated with |
xs |
the template sequence of states |
ts |
the times at which the track is sampled |
fixed |
a logical vector indicating which locations in the template path are to be held fixed. |
point.check |
function that accepts a state and returns boolean indicating whether the state is acceptable. |
random.rotation |
the upper and lower limits (radians) of the rotation applied to the VAR(1) model. |
partial |
if |
Given a fitted VAR(1) model and a template track, this function generates a new track of the same length that coincides with the template at the start point and optionally other specified points along the track.
The template track must be supplied as a matrix representing a
sequence of locations where each row is a location and the columns
represent longitude and latitude. The locations must be
equispaced in time, and can be generated as the "p" location types
from crwPredict
.
The model object is generated by surrogateARModel
from a
fitted crawl track. This fits a VAR(1) model to the increments in
longitude and latitude.
Locations from the template track can be marked as fixed with the
fixed
argument. In the current implementation the first
location must always be fixed.
Additional constraints can be placed on the path by rejection
sampling through the function point.check
. This function
must accept a state and return a boolean indicating whether the
point is acceptable. For example, the track can be constrained to
the ocean by supplying a point.check
function that compares
the state to a land mask and returns FALSE
for states
corresponding to locations that fall on land.
An array of states the define the simulated path.
Fit first-order vector-autoregressive model to track
surrogateARModel(lonlat) surrogate_arfit(lonlat)
surrogateARModel(lonlat) surrogate_arfit(lonlat)
lonlat |
a 2-column matrix or dataframe with longitude and latitude of each point |
This function fits the vector AR(1) model used as the model
argument to surrogateAR
.
An object of class "ar"
Generate new tracks from a Crawl model
surrogateCrawl( model, xs, ts = 1:nrow(xs), fixed = rep(c(TRUE, FALSE, TRUE), c(1, nrow(xs) - 2, 1)), point.check = function(tm, pt) TRUE, Verr = diag(c(1e-04, 1e-04, 0.1, 0.1)), partial = FALSE )
surrogateCrawl( model, xs, ts = 1:nrow(xs), fixed = rep(c(TRUE, FALSE, TRUE), c(1, nrow(xs) - 2, 1)), point.check = function(tm, pt) TRUE, Verr = diag(c(1e-04, 1e-04, 0.1, 0.1)), partial = FALSE )
model |
a list with the transition and covariance matrices corresponding to the fitted movement model. |
xs |
the template sequence of states |
ts |
the times at which the track is sampled |
fixed |
a logical vector indicating which locations in the template path are to be held fixed. |
point.check |
function that accepts a state and returns boolean indicating whether the state is acceptable. |
Verr |
error covariance for fixed points. |
partial |
if |
Given a fitted crawl model and a template track, this function generates a new track of the same length that coincides with the template at the start point and optionally other specified points along the track.
The template track must be supplied as a matrix representing a
sequence of states where each row is a state and each column a
state variable. The states must be equispaced in time, and can be
generated as the "p" location types from crwPredict
.
The crawl model object is generated by crawlModel
from a
fitted crawl model.
Locations from the template track can be marked as fixed with the
fixed
argument. In the current implementation the first
location must always be fixed.
Additional constraints can be placed on the path by rejection
sampling through the function point.check
. This function
must accept a state and return a boolean indicating whether the
point is acceptable. For example, the track can be constrained to
the ocean by supplying a point.check
function that compares
the state to a land mask and returns FALSE
for states
corresponding to locations that fall on land.
An array of states the define the simulated path.
Generate Transition and Covariance Matrices for a simple Crawl Model
surrogateCrawlModel(fit, dt)
surrogateCrawlModel(fit, dt)
fit |
a fitted crawl object |
dt |
the fixed time increment |
Generates the transition and covariance matrices of the state
space model for time increment dt
, corresponding to a
fitted crawl model with no drift and no covariates.
Currently no polar adjustment is made.
The matrices are generated assuming the state variables are stored
as a vector in the order longitude mu and nu then latitude mu and
nu. The parametrization is defined as in the crawl source not the
paper, which differs by a factor of in the
definition of
.
A list containing
A |
the transition matrix |
Q |
the covariance matrix |
dt |
the time increment |