ssn2DataFrames: Convert all components of a SpatialStreamNetwork object into...

Description Usage Arguments Value Examples

View source: R/ssn2DataFrames.R

Description

This function takes a SpatialStreamNetwork and returns a list of one to three data.frame objects. The first data.frame object is for the stream edges and the second is for the observed points. The third data.frame is only produced when preds = TRUE. An example of how function could be used is to convert a SpatialStreamNetwork into a series of data.frame objects to plot with ggplot2.

Usage

1
ssn2DataFrames(ssn, preds = FALSE)

Arguments

ssn

An object of class SpatialStreamNetwork.

preds

A logical to specify whether the prediction points in the SSN (if any) should be coerced to data.frame. Defaults to FALSE.

Value

A list. The list contains at least two elements. The first element will be the data.frame equivalent of the edges shapefile, obtained in the same format as the output of a ggplot2::fortify() call on a SpatialLines* object. This data.frame will also include the attributes of the edges. The second element will be data.frame equivalent of the obspoints slot in the SpatialStreamNetwork, including both the point.data and the point.coords slots. The third element will only be returned if preds = TRUE. This is the data.frame equivalent of the predpoints slot, processed in exactly the same way as the obspoint slot discussed previously.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 

# Create a SSN

s <- createSSN(100, binomialDesign(10), 
binomialDesign(10), paste(tempdir(), "s.ssn", sep = "/"), TRUE)

# Coerce to data.frame

s_df <- ssn2DataFrames(ssn = s, preds = TRUE)

# Check elements

names(s_df)



## End(Not run)

apear9/SSNdesign documentation built on Feb. 19, 2020, 4:29 a.m.