R-spatial evolution
Please note, spatsoc has followed updates from R spatial, GDAL and PROJ for
handling projections, see more at
https://r-spatial.org/r/2020/03/17/wkt.html.
In addition, group_lines
(and build_lines) previously used
sp::SpatialLines, rgeos::gIntersects, rgeos::gBuffer but have been
updated to use sf::st_as_sf, sf::st_linestring, sf::st_intersects, and
sf::st_buffer according to the R-spatial evolution, see more at
https://r-spatial.org/r/2022/04/12/evolution.html.
Notes on arguments
The DT
must be a data.table
. If your data is a
data.frame
, you can convert it by reference using data.table::setDT.
The id
, coords
, sortBy
(and optional timegroup
and splitBy
) arguments expect the names of respective columns in
DT
which correspond to the individual identifier, X and Y coordinates,
sorting, timegroup (generated by group_times) and additional grouping
columns.
The projection
argument expects a numeric or character defining the
coordinate reference system. For example, for UTM zone 36N (EPSG 32736), the
projection argument is either projection = 'EPSG:32736'
or projection = 32736
. See details in sf::st_crs()
and
https://spatialreference.org for a list of EPSG codes.
The sortBy
argument is used to order the input DT
when creating sf
LINESTRINGs. It must a column in the input DT
of type POSIXct to ensure the
rows are sorted by date time.
The threshold
must be provided in the units of the coordinates. The
threshold
can be equal to 0 if strict overlap is intended, otherwise it
should be some value greater than 0. The coordinates must be planar
coordinates (e.g.: UTM). In the case of UTM, a threshold = 50
would
indicate a 50m distance threshold.
The timegroup
argument is optional, but recommended to pair with
group_times. The intended framework is to group rows temporally with
group_times then spatially with group_lines (or group_pts,
group_polys). With group_lines, pick a relevant group_times threshold
such as '1 day'
or '7 days'
which is informed by your study species,
system or question.
The splitBy
argument offers further control building LINESTRINGs. If in
your input DT
, you have multiple temporal groups (e.g.: years) for example,
you can provide the name of the column which identifies them and build
LINESTRINGs for each individual in each year. The grouping performed by
group_lines will only consider rows within each splitBy
subgroup.