as.SpatialLines.SpatialStreamNetwork: Methods to convert SpatialStreamNetwork objects classes to sp...

View source: R/SSN-methods.R

as.SpatialLinesR Documentation

Methods to convert SpatialStreamNetwork objects classes to sp classes

Description

Converts SpatialStreamNetwork objects to sp objects.

Usage

## S3 method for class 'SpatialStreamNetwork'
as.SpatialLines(x, ...)
## S3 method for class 'SpatialStreamNetwork'
as.SpatialPoints(x, data = "Obs", ...)
## S3 method for class 'SpatialStreamNetwork'
as.SpatialLinesDataFrame(x, ...)
## S3 method for class 'SpatialStreamNetwork'
as.SpatialPointsDataFrame(x, data = "Obs", ...)

Arguments

x

an SpatialStreamNetwork object to be converted to class SpatialLines, SpatialPoints, SpatialLinesDataFrame or SpatialPointsDataFrame from the sp package.

data

the data set in the SpatialStreamNetwork object to convert. The SpatialStreamNetwork object can hold multiple spatial point data sets, including the observed data and multiple prediction data sets. See SpatialStreamNetwork-class.

...

optional arguments for specific methods written for these generics

Value

as.SpatialLines.SpatialStreamNetwork converts an object of class SpatialStreamNetwork to an object of class SpatialLines from the sp package, as.SpatialPoints.SpatialStreamNetwork converts an object of class SpatialStreamNetwork to an object of class SpatialPoints from the sp package, and as.SpatialPointsDataFrame.SpatialStreamNetwork converts an object of class SpatialStreamNetwork to an object of class SpatialPointsDataFrame from the sp package,

Author(s)

Jay Ver Hoef support@SpatialStreamNetworks.com

See Also

spplot

Examples


library(SSN)
#for examples, copy MiddleFork04.ssn directory to R's temporary directory
copyLSN2temp()
# NOT RUN
# Create a SpatialStreamNetork object that also contains prediction sites
#mf04p <- importSSN(paste0(tempdir(),'/MiddleFork04.ssn'), 
#  predpts = "pred1km", o.write = TRUE)
#use mf04p SpatialStreamNetwork object, already created
data(mf04p)
#for examples only, make sure mf04p has the correct path
#if you use importSSN(), path will be correct
mf04p <- updatePath(mf04p, paste0(tempdir(),'/MiddleFork04.ssn'))

names(mf04p)

#---------
# make plots using sp methods
#---------
#plot the stream lines
plot(as.SpatialLines(mf04p), col = "blue")
# add the observed locations with size proportional 
# to mean summer temperature
plot(as.SpatialPoints(mf04p), pch = 19, 
  cex = as.SpatialPointsDataFrame(mf04p)$Summer_mn/9 , add = TRUE)
# add the prediction locations on the 1 km spacing
plot(as.SpatialPoints(mf04p, data = "pred1km"), cex = 1.5, add = TRUE)
# add the dense set of points for block prediction on Knapp segment
plot(as.SpatialPoints(mf04p, data = "Knapp"), pch = 19, cex = 0.3, 
  col = "red", add = TRUE)


SSN documentation built on March 7, 2023, 5:30 p.m.