openSTARS (version 1.0.0)

export_ssn: Export 'SSN' object

Description

This function exports the calculated sites, edges and binary IDs to a folder which then can be read using the 'SSN' package.

Usage

export_ssn(path, predictions = NULL, delete_directory = FALSE)

Arguments

path

character; path to write .ssn object to.

predictions

name(s) of prediction map(s) (optional).

delete_directory

boolean; shall the ssn directory and all files be deleted before export in case it already exists? See details.

Value

Nothing. Files are written to the specified folder

Details

First it is checked if one of the column names is longer than 10 characters (which cannot be exported to ESRI shape files as required by 'SSN').

delete_directory = TRUE is useful if the same directory name has been used before and the existing data shall be overwritten.

Examples

Run this code
# NOT RUN {
# Initiate GRASS session
if(.Platform$OS.type == "windows"){
  gisbase = "c:/Program Files/GRASS GIS 7.2.0"
  } else {
  gisbase = "/usr/lib/grass72/"
  }
initGRASS(gisBase = gisbase,
    home = tempdir(),
    override = TRUE)

# Load files into GRASS
dem_path <- system.file("extdata", "nc", "elev_ned_30m.tif", package = "openSTARS")
sites_path <- system.file("extdata", "nc", "sites_nc.shp", package = "openSTARS")
setup_grass_environment(dem = dem_path, sites = sites_path)
import_data(dem = dem_path, sites = sites_path)
gmeta()

# Derive streams from DEM
derive_streams(burn = 0, accum_threshold = 700, condition = TRUE, clean = TRUE)

# Check and correct complex junctions (there are no complex juctions in this 
# example date set)
cj <- check_compl_junctions()
if(cj){
  correct_compl_junctions()
}

# Prepare edges
calc_edges()

# Prepare site
calc_sites()

# Write data to SSN Folder
ssn_dir <- file.path(tempdir(), 'nc.ssn')
export_ssn(ssn_dir, delete_directory = TRUE)
list.files(ssn_dir)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab