Converts an sf object with POINT geometries and a timestamp column to a ctdf.
The source CRS is taken from x; a missing CRS is an error.
Usage
# S3 method for class 'sf'
as_ctdf(x, time = "time", t_srs = "+proj=eqearth", ...)Arguments
- x
An
sfobject with POINT geometries and a source CRS.- time
Name of the POSIXt time column. Will be renamed to
"timestamp"internally.- t_srs
Target spatial reference passed to
sf::st_transform(). Default is "+proj=eqearth".- ...
Currently unused
Value
An object of class ctdf (inherits from data.table and data.frame),
with an sfc_POINT geometry column named location.
Details
Rows are sorted by timestamp, geometry is transformed to t_srs, and
clusterTrack columns are initialized. Existing reserved columns are overwritten
with a warning.
The converted object is checked for duplicate locations with the same timestamp
and temporal gaps exceeding getOption("clusterTrack.max_gap", 24) hours.
Duplicate warnings identify row positions in the returned, timestamp-sorted ctdf.
ctdf columns
In addition to columns retained from the input, a ctdf contains the
following standardized columns:
timestamp: Observation time. Rows are ordered by this column when thectdfis created.location: Point geometry in the target coordinate reference system..id: Sequential row identifier assigned after ordering bytimestamp. It is used internally to track locations through the clustering workflow and does not refer to the row number in the original input.cluster: Final cluster assignment. It is initialized toNA.cluster_track()assigns positive integers to clustered locations and0to unassigned locations.aggregate_ctdf()may subsequently merge and renumber clusters.lof: Local Outlier Factor score for each location. It is initialized toNAand populated byctdf_lof()for locations withcluster > 0. Unassigned locations retainNA.
