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:
# 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)