This function writes an SSN object to a local .ssn directory

ssn_write(ssn, path, overwrite = FALSE, copy_dist = FALSE, import = FALSE)

Arguments

ssn

An SSN object.

path

filepath to the local .ssn directory to write to.

overwrite

If TRUE, overwrite existing files in file (if it exists). Defaults to FALSE.

copy_dist

If TRUE, copy distance matrices to file (if they exist). Defaults to FALSE.

import

If TRUE, import and return the SSN object after writing to file. Defaults to FALSE.

Value

ssn_write creates an .ssn directory that contains the spatial, topological, and attribute information stored in the original SSN object. Spatial datasets found in the SSN object (e.g. edges, obs, and prediction sites) are saved in GeoPackage format. When import = TRUE, the SSN object is imported and returned.

Examples

# Copy the mf04p .ssn data to a local directory and read it into R
# When modeling with your .ssn object, you will load it using the relevant
# path to the .ssn data on your machine
copy_lsn_to_temp()
temp_path <- paste0(tempdir(), "/MiddleFork04.ssn")
## Import SSN object with prediction sites
mf04p <- ssn_import(temp_path,
  predpts = "pred1km",
  overwrite = TRUE
)

## Write SSN to new .ssn directory
ssn_write(mf04p,
  path = paste0(tempdir(), "/tempSSN.ssn"),
  overwrite = TRUE
)

## Write SSN to .ssn directory and return SSN object
tempSSN <- ssn_write(mf04p, path = paste0(
  tempdir(),
  "/tempSSN.ssn"
), overwrite = TRUE, import = TRUE)
#> netgeom exists in predpts and overwrite == FALSE. No changes made to netgeom