Learn R Programming

opentraj (version 1.0)

Df2SpLines: Data Frame to Spatial Lines

Description

This function converts an object of type data.frame, calculated by the function ProcTraj, into an object of type SpatialLines-class.

Usage

Df2SpLines(df, crs=NA)

Arguments

df
data.frame Object created by the function ProcTraj.
crs
String: Valid projection string. An example would be crs="+proj=longlat +datum=NAD27"

Value

Returns an object of class SpatialLines-class.

Details

An individual line consists of a set of lines in the data frame that contains the same ID. This function identifies individual trajectories based on their length. It is assumed that all trajectories calculated by HySplit using the ProcTraj function have the same length. Thus, once known the length of the trajectories, this function splits the data frame in X different data frames where each data frame contains R rows, R being the trajectory's length and X being the number of rows in the initial data frame divided by the trajectory's length. Each of the X different data frames will be transformed into a different line.

See Also

data.frame, ProcTraj, SpatialLines-class.

Examples

Run this code
  ## load data frame of HYSPLIT trajectory calculations calculated by function ProcTraj
  crs <- "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0"
  air.traj.lines <- Df2SpLines(air.traj, crs)
  PlotTraj(air.traj.lines)

Run the code above in your browser using DataLab