Learn R Programming

SSN (version 1.1.8)

reachNeiSSN: Find neighboring stream segments

Description

Create a neighborhood matrix of 0's and 1's that indicate the neighboring stream segments (reaches) of each stream segment

Usage

reachNeiSSN(object)

Arguments

object
An object of class SpatialStreamNetwork-class

Value

A sparse matrix.

Details

Returns a sparse matrix with 1's indicating neighboring stream segments (reaches). The rownames and colnames are the same as the "rid" values for the stream segments. That is, the data.frame for the stream segments is in the @data slot of the SpatialStreamNetwork-class object, and that data.frame always has a unique reach identifier in the "rid" column.

Examples

Run this code

library(SSN)
# NOT RUN 
# mf04 <- importSSN(system.file("lsndata/MiddleFork04.ssn", 
#	        package = "SSN"), o.write = TRUE)
# use SpatialStreamNetwork object mf04 that was already created
data(mf04)
# for examples, copy MiddleFork04.ssn directory to R's temporary directory
copyLSN2temp()
#make sure mf04p has the correct path, will vary for each users installation
mf04 <- updatePath(mf04, paste0(tempdir(),'/MiddleFork04.ssn'))

neiMat = reachNeiSSN(mf04)
all(rownames(neiMat) == mf04@data$rid)

Run the code above in your browser using DataLab