library(SSN)
## Create temporary .ssn directory to work with
old.wd <- getwd()
setwd(system.file("lsndata/MiddleFork04.ssn",package = "SSN"))
file.list <- list.files()
dir.create("tmp.ssn")
file.copy(file.list, "tmp.ssn", recursive = TRUE)
## Import the SpatialStreamNetwork object
mf04 <- importSSN("tmp.ssn", predpts = "pred1km")
# Split using the chunksof method
split1 <- splitPredictions(mf04, "pred1km", chunksof = 100)
summary(split1)
## Split using the by method
split2 <- splitPredictions(mf04, "pred1km", by = "netID")
summary(split2)
## Split using the subset method
split3 <- splitPredictions(mf04, "pred1km", subset = netID == 1,
new.id="netID-1")
summary(split3)
## Split the predictions after creating a glmssn object
mf04.glmssn <- glmssn(Summer_mn ~ ELEV_DEM + SLOPE, mf04,
CorModels = c("Exponential.tailup", "Exponential.taildown",
"Exponential.Euclid"),addfunccol = "afvArea")
mf04.glmssn$ssn.object <- splitPredictions(mf04.glmssn$ssn.object, "pred1km",
subset = netID == 1, new.id="netID-1")
pred.split<- predict(mf04.glmssn, "netID-1")
plot(pred.split)
## Delete temporary files and return to workspace
unlink("tmp.ssn", recursive = TRUE)
setwd(old.wd)
Run the code above in your browser using DataLab