Adds a spatial trajectory using coordinate input.

addSpatialTrajectory(
  object,
  id,
  width = NULL,
  traj_df = NULL,
  start = NULL,
  end = NULL,
  comment = base::character(1),
  overwrite = FALSE,
  ...
)

Arguments

object

An object of class SPATA2 or, in case of S4 generics, objects of classes for which a method has been defined.

id

Character value. The id of the spatial trajectory.

width

Distance measure. The width of the spatial trajectory.

start, end

Numeric vectors of length two. Can be provided instead of segment_df. If so, start corresponds to x and y and end corresponds to xend and yend of the segment.

overwrite

Logical value. Must be TRUE to allow overwriting.

...

Used to absorb deprecated arguments or functions.

segment_df

Data.frame with x and y as variables corresponding to the vertices of the trajectory. IN case of more than three rows the trajectory is assumed to have a curve.

vertices

List of numeric vectors of length two or NULL. If list, sets additional vertices along the trajectory.

Value

The updated input object, containing the added, removed or computed results.

Examples


library(SPATA2)
library(tidyverse)

data("example_data")

object <- example_data$object_UKF275T_diet

object <-
   addSpatialTrajectory(
     object = object,
     id = "cross_sample",
     width = "1.5mm",
     start = c(x = "1.35mm", y = "4mm"),
     end = c(x = "6.25mm", y = "4mm"),
     overwrite = TRUE
   )

 plotSpatialTrajectories(object, ids = "cross_sample")