Learn R Programming

Watersheds (version 1.1)

Watershed.IOR3: Watershed inlet and outlet nodes: case 3

Description

The function determines the inlet and outlet nodes for zhyd watershed objects. This case 3 is for those watersheds that its river inlet and outlet object is length 3 (length(riverIO)=3).

Usage

Watershed.IOR3(x, y, dist)

Arguments

x
An object "SpatialPointsDataFrame" as is described in package sp over them the function will search the inlet and outlet nodes of the watershed.
y
An object "SpatialLinesDataFrame" as is described in package sp that represents the inlet and outlet rivers of the watershed.
dist
A vector with the distances of each point in x to the current zhyd boundary.

Value

inlet
A "SpatialPointsDataFrame" that represents the inlet node of the current zhyd.
outlet
A "SpatialPointsDataFrame" that represents the outlet node of the current zhyd.

See Also

See Also the functions Watershed.IOR1, Watershed.IOR2, Watershed.IOR4.

Examples

Run this code
library(Watersheds)
data(WatershedsData)

station1 = WatershedsData$station
subbasin1 = WatershedsData$subbasin
zhyd1 = WatershedsData$zhyd
river1 = WatershedsData$river
node1 = WatershedsData$node	

station1 = SpatialPoints(coords=cbind(4217199.42,3353511.83), 
	proj4string=slot(subbasin1,"proj4string"))
watershed = new("Watershed",station=station1,subbasin=subbasin1,
	zhyd=zhyd1,river=river1,c1=subbasin1,node=node1)

a = Watershed.Order(watershed)
c1 = a[[1]]
riverIO = a[[8]]
nodeIO = a[[9]]			
c1_river = a[[10]]
		
# determining inlet and outlet watershed nodes
	# determining distances of nodeIO to c1
	boundary = gBoundary(c1)
	dist = gDistance(nodeIO, boundary, byid =TRUE)
	a = Watershed.IOR3(x=nodeIO, y=riverIO, dist=dist)	
	c1_inlet = a$inlet; c1_inlet
	c1_outlet = a$outlet; c1_outlet
	
plot(c1,col="gray60")			
plot(station1,pch=24, bg="blue",add= TRUE)
plot(c1_river, col="blue", add=TRUE)
plot(c1_outlet,pch=21, bg="red",add= TRUE)
plot(c1_inlet,pch=21, bg="green",add= TRUE)
plot.PointAttribute(c1_outlet,"ELEV",1000,0.8)
plot.PointAttribute(c1_inlet,"ELEV",1000,0.8)
title(main="Watershed outlet and inlet, case III")

Run the code above in your browser using DataLab