# NOT RUN {
dem_path <- system.file("extdata", "nc", "elev_ned_30m.tif", package = "openSTARS")
if(.Platform$OS.type == "windows"){
grass_program_path = "c:/Program Files/GRASS GIS 7.6"
} else {
grass_program_path = "/usr/lib/grass78/"
}
setup_grass_environment(dem = dem_path,
gisBase = grass_program_path,
remove_GISRC = TRUE,
override = TRUE
)
gmeta()
# 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")
streams_path <- system.file("extdata", "nc", "streams.shp", package = "openSTARS")
import_data(dem = dem_path, sites = sites_path, streams = streams_path)
# Derive streams from DEM
derive_streams(burn = 10, accum_threshold = 700, condition = TRUE, clean = TRUE)
# Plot
library(sp)
dem <- readRAST('dem', ignore.stderr = TRUE)
sites <- readVECT('sites_o', ignore.stderr = TRUE)
streams_o <- readVECT('streams_o', ignore.stderr = TRUE)
streams <- readVECT('streams_v', ignore.stderr = TRUE)
plot(dem, col = terrain.colors(20))
lines(streams, col = 'blue', lwd = 2)
lines(streams_o, col = 'lightblue', lwd = 1)
legend("topright", col = c("lightblue", "blue"), lwd = c(1,2),
legend = c("read in streams for burn in", "derived streams"))#'
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab