LOStest: Line-of-Sight test for two water locations

View source: R/LOStest.R

LOStestR Documentation

Line-of-Sight test for two water locations

Description

Determines whether land is obstructing a direct path between two pairs of ocean coordinates.

Usage

LOStest(pts.ocean, buffer = 0.025, toplot = TRUE)

Arguments

pts.ocean

A list containing two coordinate pairs. Format: list(c(X1,Y1),c(X2,Y2)).

buffer

Distance (in decimal degrees) to increase the boundaries of shoreline under consideration beyond the range defined by the two points.

toplot

If TRUE (the default), then two plot will be generated to show the process. The top plot is a "context" plot showing the two points. The bottom plot is a zoom of the two points. A blue line connects them, and the green line along the shore indicates shoreline coordinates that have been tested for line-of-sight obstruction. When an obstruction has been found, a circle marks the shoreline intersection point (corresponding to element two of returned list).

Details

A test function used frequently throughout the routeKFS function, but can be used on its own for any part of the northeast Pacific coastline (Oregon to Alaska). The function takes a shoreline dataset from the package PBSmapping, and explores nearby shoreline vertices (in pairs) to see if the line connecting them intersects with a straight path between the two ocean points in question. Then, if the solution of the two lines is contained with a box that bounds the two shoreline vertices, the function concludes that the shore must be obstructing line of sight.

Value

Returns a two element list. The first list is a Boolean: If TRUE, then the two points are indeed line-of-sight with no shore obstructions. If FALSE, then the land is obstructing the most direct path between the points. The second element in the list is a 2-element vector, the X and Y of the intersection point with shore. This vector is c(NA,NA) when the two points are line of sight.

Author(s)

Eric Keen, Scripps Institution of Oceanography, ekeen@ucsd.edu

See Also

whalemap, routeKFS, solve2lines

Examples

### Define the two ocean pts
xO1 <- -129.3
yO1 <- 53.3
xO2 <- -129.23
yO2 <- 53.33
# Combine into list
pts.ocean <- list(c(xO1,yO1),c(xO2,yO2))
# Run the test:
LOStest(pts.ocean)

ericmkeen/bangarang documentation built on Feb. 10, 2024, 2:58 p.m.