Hi, I am having an issue with getting prediction points to show up in ssn object via export_ssn() and importSSN(). I have tried this with 2 data sets code below is the nc dataset.
I am using mac OS with grass8.
library("openSTARS")
give paths to GRASS and where to store the GRASS data base
Hi, I am having an issue with getting prediction points to show up in ssn object via export_ssn() and importSSN(). I have tried this with 2 data sets code below is the nc dataset.
I am using mac OS with grass8.
library("openSTARS")
give paths to GRASS and where to store the GRASS data base
mac OS
grass_program_path<- "/Applications/GRASS-8.2.app/Contents/Resources"
working_dir <- file.path(tempdir(), "grass_workflow") grass_db_path <- file.path(working_dir, "grassDB") dir.create(working_dir) setwd(tempdir()) grass_db_path
specify the path to the digital elevation model
dem_path <- system.file("extdata", "nc", "elev_ned_30m.tif", package = "openSTARS")
setup_grass_environment(dem = dem_path, gisBase = grass_program_path, gisDbase = grass_db_path, location = "ncloc", remove_GISRC = TRUE, override = TRUE )
the observation sites
sites_path <- system.file("extdata", "nc", "sites_nc.shp", package = "openSTARS")
existing stream network
streams_path <- system.file("extdata", "nc", "streams.shp", package = "openSTARS") import_data(dem = dem_path, sites = sites_path, streams = streams_path) derive_streams(accum_threshold = 200, condition = T, clean = TRUE, burn = 10)
calc_edges() calc_sites()
the stream segment the point lies on (equivalent to 'rid').
calc_prediction_sites(predictions = "preds", nsites = 100, netIDs = 35)
calculate slope from DEM as an example attribute
execGRASS("r.slope.aspect", flags = c("overwrite","quiet"), parameters = list( elevation = "dem", slope = "slope" ))
calculate average slope per sub-catchment of each stream segment using raster data
calc_attributes_edges(input_raster = c("slope"), stat_rast = c("mean"), attr_name_rast = c("avSlo"), round_dig = 4)
calculate approx. catchment area, average slope per catchment and percentage of land use class of each site
calc_attributes_sites_approx(sites_map = "sites", input_attr_name = c("avSlo"), output_attr_name = c("avSloA"), stat = c("mean"), overwrite = T) calc_attributes_sites_approx(sites_map = "preds", input_attr_name = c("avSlo"), output_attr_name = c("avSloA"), stat = c("mean"), overwrite = T)
Write all files to an ssn folder
ssn_dir <- file.path(tempdir(), 'nc.ssn') export_ssn(ssn_dir, predictions = 'preds', delete_directory = T) list.files(ssn_dir)
Try with SSN package
library(SSN)
import
ssn_obj <- importSSN(ssn_dir, o.write = TRUE)
ISSUE PREDPOINTS ARE NOT HELD WITHING SSN OBJECT