distSeg: Computes distances between the top coordinates of segments.

View source: R/distSeg.r

distSegR Documentation

Computes distances between the top coordinates of segments.

Description

Computes the distances between the top coordinates of segments.

Usage

distSeg(mydata,decdeg=FALSE)

Arguments

mydata

A matrix or data frame of 4 columns giving the coordinates of each segment tops x1, y1, x2, y2

decdeg

TRUE if point coordinates are longitude-latitude decimal degrees, in which case distances are measured in meters

Details

If degdec is FALSE (default), distance computed is Euclidian. Units depends on the coordinate systems. If decdeg = TRUE, D = 1852 * 60 * (180/pi) * acos ( sin(la1) * sin(la2) + cos(la1) * cos(la2) * cos(abs(lg1 - lg2)). This method calculates the great circle distance, is based on spherical trigonometry, and assumes that:

  • 1 minute of arc is 1 nautical mile

  • 1 nautical mile is 1.852 km

When computing with decdeg=TRUE duplicated coordinates strictly identical can lead to produce NaN. The corresponding distance is coerced to zero with warnings and if so, an attribute 'NaNcoerced2zero' with the row numbers of the distances that have been coerced to zero is created

Value

A vector of distances, possibly with the attribute 'NaNcoerced2zero' with the row numbers of the distances that have been coerced to zero if any.

See Also

distNode, distTot

Examples

x1<-rnorm(20)
y1<-rnorm(20)
x2<-rnorm(20)
y2<-rnorm(20)
mydata<-cbind(x1,y1,x2,y2)
distSeg(mydata)

pgirmess documentation built on April 8, 2023, 1:12 a.m.

Related to distSeg in pgirmess...