sl.line.polygon.intersect: Check if/where Line Intersects with Polygon

Description Usage Arguments Details Value Author(s) Examples

View source: R/sl.line.polygon.intersect.R

Description

Check if and where a line intersects with a polygon on a sphere.

Usage

1
sl.line.polygon.intersect(line.lon, line.lat, polygon.lon, polygon.lat)

Arguments

line.lon

a vector of length 2 giving the longitudes of the points of the first line.

line.lat

a vector of length 2 giving the latitudes of the points of the first line.

polygon.lon

a vector of length N giving the longitudes of the points defining the polygon.

polygon.lat

a vector of length N giving the latitudes of the points defining the polygon.

Details

This functions is based on sl.line.line.intersect, which is applied to every line segment of the polygon.

Value

anylines.intersect

a logical value indicating whether the line intersects with the polygon at all.

lines.intersect

a vector of length N with logical values indicating for each segment of the polygon whether the line intersects with the segment (on the shorter ways!).

lon,lat,lon2,lat2,x,y,z,x2,y2,z2

vectors of length N with coordinates for each segment of the polygon where the line intersects with the segment, be it on the shorter or longer ways of the great-circle lines. If the line and the segment intersect on the shorter way (as indicated by lines.intersect), that point will be in the first set of output variables (that is, the variables without '2' in the name).

Author(s)

Helge Goessling

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
sl.line.polygon.intersect(line.lon=c(-10,10),line.lat=c(0,5),polygon.lon=c(-5,5,0),polygon.lat=c(0,0,5))
## Should return:
## $anylines.intersect
## [1] TRUE
## 
## $lines.intersect
## [1] FALSE  TRUE  TRUE
## 
## $lon
## [1] 170.000000   1.970366  -3.295047
## 
## $lat
## [1] 0.000000 3.036942 1.710705
## 
## $lon2
## [1]  -10.0000 -178.0296  176.7050
## 
## $lat2
## [1]  0.000000 -3.036942 -1.710705
## 
## $x
## [1] -0.01490451  0.03703484  0.02213033
## 
## $y
## [1]  0.002628067  0.001274107 -0.001274107
## 
## $z
## [1] 0.0000000000 0.0019660214 0.0006620458
## 
## $x2
## [1]  0.01490451 -0.03703484 -0.02213033
## 
## $y2
## [1] -0.002628067 -0.001274107  0.001274107
## 
## $z2
## [1]  0.0000000000 -0.0019660214 -0.0006620458

helgegoessling/spheRlab documentation built on Sept. 29, 2017, 6:36 a.m.