Learn R Programming

rsgeo (version 0.1.7)

length_euclidean: Calculate LineString Length

Description

For a given LineString or MultiLineString geometry, calculate its length. Other geometries will return a value of NA.

Usage

length_euclidean(x)

length_geodesic(x)

length_vincenty(x)

length_haversine(x)

Value

A numeric vector

Arguments

x

an object of class rsgeo

Details

Notes

  • Vicenty, Geodesic, and Haversine methods will return in units of meters.

  • Geodesic length will always converge and is more accurate than the Vicenty methods.

  • Haversine uses a mean earth radius of 6371.088 km.

See geo docs for more details.

Examples

Run this code
set.seed(0)
y <- runif(25, -5, 5)
x <- 1:25

ln <- geom_linestring(x, y)

length_euclidean(ln)
length_geodesic(ln)
length_vincenty(ln)
length_haversine(ln)

Run the code above in your browser using DataLab