During this workshop, we will demonstrate the TuktuTools
package, which has been developed for studying Tuktu (caribou) movement
ecology and spatial patterns.
To date, this package contains functions that prep and filter movement data:
process_moveNWT
- processes data from Movebank;removeoutliers
- flags fixes considered as
outliers;prepData
- prepares and filters data to a specific
period of time and/or a minimum number of fixes per day;scan_tracks
- visualizes individual paths through
timeThe package also contains functions that analyze spatial patterns,
including: - getSpeed
- computes individual movement rates,
displacements, speeds; - getDailyMean
- estimates
individual mean daily location (i.e., the mean x and y coordinates of
all the daily locations for a given individual); - getLoCoH
and getKernelUD
- estimates ranging areas with Local Convex
Hulls (LoCoH) or Kernel Utilization Distributions (KUD); -
getPairwiseDistance
and getPairwiseOverlap
-
estimates daily pairwise distance or pairwise overlap between pairs of
individuals; - estimateCalving
- estimates calving status
(non-calving or calving, calving with survival or calving with calf
death), calving timing, and calving location for given females, using
movement rate; - estimateMigration_stan
- estimates
population-level migration timing using STAN
The package contains the following data:
caribou
- anonymized movement data for 4 individual
Barren-ground caribou;simulated_migrations
- simulated movement tracks for 18
individualsMost of the functions in this package have been developed to handle
simple features. Simple features, supported by the package
sf
, are georeferenced spatial objects, allowing to easily
project data on a map, transform the projection and manipulate the data
(e.g., link points into lines, union polygons, etc.).
To install the current version of this package in R:
install.packages("devtools")
devtools::install_github("ocouriot/TuktuTools", build_vignettes = TRUE)
Load the package:
require(TuktuTools)
The TuktuTools
package contains real movement data from
4 barren-grond caribou from the Bathurst herd in the Northwest
Territories, which have been anonymized and shifted spatially and
temporally. The package also contains data of 18 simulated tracks of
caribou, during the spring migration.
To see a list of these datasets, enter:
data(package = 'TuktuTools')
The caribou
dataset contains real movement data for 4
caribou individuals. It contains the ID
of the individuals,
the sex
, as well as the Time
and
Lon
,Lat
(in WGS 84, epsg: 4326) and
x
,y
(UTM zone 10N, epsg: 32610) coordinates of
their GPS locations.
data(caribou)
head(caribou)
## ID sex Time Year Lon Lat x y
## 1 Dancer f 2002-04-01 00:00:00 2002 -133.8427 62.77028 -51589.97 7006600
## 2 Dancer f 2002-04-01 08:00:00 2002 -133.8394 62.76716 -51480.43 7006228
## 3 Dancer f 2002-04-01 16:00:00 2002 -133.8453 62.77767 -51584.51 7007437
## 4 Dancer f 2002-04-02 00:00:00 2002 -133.8643 62.80010 -52121.93 7010074
## 5 Dancer f 2002-04-02 08:00:00 2002 -133.8621 62.79918 -52024.50 7009953
## 6 Dancer f 2002-04-02 16:00:00 2002 -133.8625 62.80007 -52030.49 7010055
These data are very typical examples of movement data. The key
columns are individual identifies (ID
), a time stamp
(Time
), and coordinates. Here there are longitude and
latitude coordinates.
The following steps are absolutely essential to master - in general -
for dealing with movement data. They require the following three
packages: sf
, lubridate
and
mapview
.
Currently, the most powerful tool for working with data is the
simple feature (sf
) package, which is a
versatile, flexible, relatively easy to use structure for spatial data.
Creating a “simple feature” object with st_as_sf
:
require(sf)
caribou.sf <- st_as_sf(caribou,
coords = c("Lon","Lat"), crs = 4326)
caribou.sf
## Simple feature collection with 18074 features and 6 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -134.4759 ymin: 62.60674 xmax: -122.6872 ymax: 66.12819
## Geodetic CRS: WGS 84
## First 10 features:
## ID sex Time Year x y
## 1 Dancer f 2002-04-01 00:00:00 2002 -51589.97 7006600
## 2 Dancer f 2002-04-01 08:00:00 2002 -51480.43 7006228
## 3 Dancer f 2002-04-01 16:00:00 2002 -51584.51 7007437
## 4 Dancer f 2002-04-02 00:00:00 2002 -52121.93 7010074
## 5 Dancer f 2002-04-02 08:00:00 2002 -52024.50 7009953
## 6 Dancer f 2002-04-02 16:00:00 2002 -52030.49 7010055
## 7 Dancer f 2002-04-03 00:00:00 2002 -51569.55 7009647
## 8 Dancer f 2002-04-03 08:00:00 2002 -53286.09 7008459
## 9 Dancer f 2002-04-03 16:00:00 2002 -50269.61 7005972
## 10 Dancer f 2002-04-04 00:00:00 2002 -49748.15 7005049
## geometry
## 1 POINT (-133.8427 62.77028)
## 2 POINT (-133.8394 62.76716)
## 3 POINT (-133.8453 62.77767)
## 4 POINT (-133.8643 62.8001)
## 5 POINT (-133.8621 62.79918)
## 6 POINT (-133.8625 62.80007)
## 7 POINT (-133.8523 62.79717)
## 8 POINT (-133.8815 62.78412)
## 9 POINT (-133.8153 62.76672)
## 10 POINT (-133.8022 62.75936)
The crs = 4326
refers to the coordinate system being -
basically - Longitude and Latitude on a nearly spherical Earth. This
particular CRS is detailed here, and the
“4326” is the so-called “EPSG” code. This is the coordinate
system used by all GPS satellite navigation systems.
In general, we do not want to work in Longitude-Latitude, but in a projected coordinate system such that the unit of North-South and East-West is in meters. For these data, for example, since we’re working in northern Canada we might choose EPSG:3347, aka Statistics Canada Lambert:
caribou.sf <- st_transform(caribou.sf, 3347)
caribou.sf
## Simple feature collection with 18074 features and 6 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: 4268069 ymin: 3484118 xmax: 4863478 ymax: 3771396
## Projected CRS: NAD83 / Statistics Canada Lambert
## First 10 features:
## ID sex Time Year x y
## 1 Dancer f 2002-04-01 00:00:00 2002 -51589.97 7006600
## 2 Dancer f 2002-04-01 08:00:00 2002 -51480.43 7006228
## 3 Dancer f 2002-04-01 16:00:00 2002 -51584.51 7007437
## 4 Dancer f 2002-04-02 00:00:00 2002 -52121.93 7010074
## 5 Dancer f 2002-04-02 08:00:00 2002 -52024.50 7009953
## 6 Dancer f 2002-04-02 16:00:00 2002 -52030.49 7010055
## 7 Dancer f 2002-04-03 00:00:00 2002 -51569.55 7009647
## 8 Dancer f 2002-04-03 08:00:00 2002 -53286.09 7008459
## 9 Dancer f 2002-04-03 16:00:00 2002 -50269.61 7005972
## 10 Dancer f 2002-04-04 00:00:00 2002 -49748.15 7005049
## geometry
## 1 POINT (4268706 3594395)
## 2 POINT (4268630 3594028)
## 3 POINT (4269093 3595106)
## 4 POINT (4269837 3597598)
## 5 POINT (4269864 3597451)
## 6 POINT (4269906 3597540)
## 7 POINT (4270113 3596983)
## 8 POINT (4268108 3596753)
## 9 POINT (4269545 3593258)
## 10 POINT (4269569 3592233)
To easily and interactively visualize spatial data, load the
mapview
package and simply run the mapview function on
these spatial data:
require(mapview)
mapview(caribou.sf)