Learn R Programming

pgirmess (version 1.3.8)

distPolylines: Computes the length of each lines of an output (polylines) of 'read.shape' from maptools.

Description

Computes the length of each lines of an output (polylines) of 'read.shape' from maptools.

Usage

distPolylines(myshp,decdeg=FALSE)

Arguments

myshp
A list of shapes of class ShapeList. The list must be of type "polylines".
decdeg
TRUE if point coordinates are longitude-latitude decimal degrees, in which case distances are measured in meters

Value

  • A numeric distance.

Details

Requires the library maptools. 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

See Also

distNode, distTot, distSeg, distTotshp

Examples

Run this code
# see example of Norwegian rivers in library maptools: ?Map2lines
 library(maptools)
 
 try4 <- read.shape(system.file("shapes/fylk-val.shp", package="maptools")[1])
 
 distPolylines(try4)

Run the code above in your browser using DataLab