Learn R Programming

pgirmess (version 1.2.8)

distTotshp: Computes the total length of the lines of an output of 'read.shape' from maptools.

Description

Computes the total length of the lines of an output of 'read.shape' from maptools.

Usage

distTotshp(lines.shp,decdeg=FALSE)

Arguments

lines.shp
A list of shapes of class ShapeList. The list must be of type "line".
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,distPolylines

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])
 
 distTotshp(try4)

Run the code above in your browser using DataLab