locate_site {rivnet}R Documentation

Locate site in a river

Description

Finds location of a site (with coordinates X, Y) within a river object.

Usage

locate_site(X, Y=NULL, river, euclidean = TRUE, showPlot = FALSE, 
  xlim = NULL, ylim = NULL)

Arguments

X

Either a list or a numeric value. If X is a list, it must contain the longitudinal and latitudinal coordinates of the site in columns x (or X) and y (or Y), respectively. If numeric, it represents the longitudinal coordinate of the site. Coordinate values must be given in the same coordinate system as the river object.

Y

Latitudinal coordinate of the site. If X is a list, it can contain the river object.

river

river object where the site is to be located. It must have been aggregated (via aggregate_river).

euclidean

Logical. Should the location of the site in the river be attributed "as the crow flies"? If FALSE, the downstream path from (X, Y) is followed until the river network is met.

showPlot

Logical. Should a close-up of the relocated site be shown?

xlim, ylim

Ranges of x- and y-axis limits for the plot. Only active if showPlots = TRUE.

Details

This function identifies the node in the river network (at the RN and AG levels) that is closest to an arbitrary site of coordinates X, Y. Only a single site can be processed per function call.

Desired coordinates X, Y can be found in an interactive way by clicking on the river map and using function locator.

Nodes at the RN level thus found can be defined as new breakpoints for reaches (see aggregate_OCN and argument breakpoints).

Value

A list with objects:

FDode

index at the FD level of the node that is closest to (X, Y). This is generally not a node that belongs to the river network.

distance

The distance between FDnode and RNnode, expressed either as Euclidean distance (if euclidean = TRUE), or as downstream distance alternatively.

RNode

index at the RN level of the relocated site.

AGode

index at the AG level of the relocated site.

par

List of graphical parameters as produced by a call to par (only if showPlot = TRUE). This can be used to add features to the existing plot.

See Also

aggregate_OCN, locator

Examples



 fp <- system.file("extdata/wigger.tif", package = "rivnet")
 r <- extract_river(outlet = c(637478, 237413),
	                  DEM = fp)					  
 r <- aggregate_river(r)
 
 X <- 641329; Y <- 227414 
 out1 <- locate_site(X, Y, r, showPlot = TRUE) # as the crow flies
 out2 <- locate_site(X, Y, r, showPlot = TRUE, euclidean = FALSE) # follow downstream path
 
 # par(out2$par) # reset graphical parameters before adding new features to the current plot
 
 
  # define X, Y by clicking on the map
 if (interactive()) {
 fp <- system.file("extdata/wigger.tif", package = "rivnet")
 r <- extract_river(outlet = c(637478, 237413),
	                  DEM = fp)					  
 r <- aggregate_river(r)
 plot(r)
 
 point <- locator(1) # click on the map to define point
 locate_site(point$X, point$Y, r)
 
 # alternative: specify X as a list and pass river as second argument
 locate_site(point, r)
 }


[Package rivnet version 0.4.2 Index]