View source: R/calc_prediction_sites.R
calc_prediction_sites | R Documentation |
A vector (points) map of prediction sites is created and several attributes are assigned.
calc_prediction_sites(predictions, dist = NULL, nsites = 10, netIDs = NULL)
predictions |
string giving the name for the prediction sites map. |
dist |
number giving the distance between the points to create in map units. |
nsites |
integer giving the approximate number of sites to create |
netIDs |
integer (optional): create prediction sites only on streams with these netID(s). |
Either dist
or nsites
must be provided. If dist
is NULL, it is estimated by dividing the total stream length in the map by
nsites
; the number of sites actually derived might therefore be a bit
smaller than nsites
.
Steps include:
Place points on edges with given distance from each other
Save the point coordinates in NEAR_X and NEAR_Y.
Assign unique identifiers (needed by the 'SSN' package) 'pid' and 'locID'.
Get 'rid' and 'netID' of the stream segment the site intersects with (from map 'edges').
Calculate upstream distance for each point ('upDist').
Calculate distance ratio ('distRatio') between position of the site on the edge (= distance traveled from lower end of the edge to the site) and the total length of the edge.
'pid' and 'locID' are identical, unique numbers. 'upDist' is calculated using r.stream.distance. Points are created using v.segment.
import_data
, derive_streams
and
calc_edges
must be run before.
Mira Kattwinkel mira.kattwinkel@gmx.net
# Initiate and setup GRASS 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") import_data(dem = dem_path, sites = sites_path) # Derive streams from DEM derive_streams(burn = 0, accum_threshold = 700, condition = TRUE, clean = TRUE) check_compl_confluences() calc_edges() calc_sites() calc_prediction_sites(predictions = "preds", dist = 2500) library(sp) dem <- readRAST('dem', ignore.stderr = TRUE, plugin = FALSE) sites <- readVECT('sites', ignore.stderr = TRUE) preds <- readVECT('preds', ignore.stderr = TRUE) edges <- readVECT('edges', ignore.stderr = TRUE) plot(dem, col = terrain.colors(20)) lines(edges, col = 'blue', lwd = 2) points(sites, pch = 4) points(preds, pch = 19, col = "darkred")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.