library(SSN)
#use mf04p SpatialStreamNetwork object, already created
data(mf04p)
#make sure mf04 has the correct path, will vary for each users installation
mf04p <- updatePath(mf04p, system.file("lsndata/MiddleFork04.ssn", package = "SSN"))
#Calculate an additive function value based on an existing column.
names(mf04p@data)
mf04p <- additive.function(mf04p, "h2oAreaKm2", "areaAFV")
#notice that a column called afvArea was already included, and "areaAFV" replicates it
# in the lines data
head(mf04p@data)
# and in the observed points data
head(getSSNdata.frame(mf04p))
# and in the prediction points data
head(getSSNdata.frame(mf04p, "pred1km"))
Run the code above in your browser using DataLab