Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

misc-gLength

Length of Geometry


Description

Calculates the length of the given geometry.

Usage

gLength(spgeom, byid=FALSE)

Arguments

spgeom

sp object as defined in package sp

byid

Logical determining if the function should be applied across subgeometries (TRUE) or the entire object (FALSE)

Value

Returns the length of the geometry in the units of the current projection. By definition [MULTI]POINTs have a length of 0. The length of POLYGONs is the sum of the length of their shell and their hole(s).

Author(s)

Roger Bivand & Colin Rundel

See Also

Examples

gLength(readWKT("POINT(1 1)"))

gLength(readWKT("LINESTRING(0 0,1 1,2 2)"))
gLength(readWKT("LINESTRING(0 0,1 1,2 0,3 1)"))

gLength(readWKT("POLYGON((0 0,3 0,3 3,0 3,0 0))"))
gLength(readWKT("POLYGON((0 0,3 0,3 3,0 3,0 0),(1 1,2 1,2 2,1 2,1 1))"))

rgeos

Interface to Geometry Engine - Open Source ('GEOS')

v0.5-5
GPL (>= 2)
Authors
Roger Bivand [cre, aut] (<https://orcid.org/0000-0003-2392-6140>), Colin Rundel [aut], Edzer Pebesma [ctb], Rainer Stuetz [ctb], Karl Ove Hufthammer [ctb], Patrick Giraudoux [ctb], Martin Davis [cph, ctb], Sandro Santilli [cph, ctb]
Initial release
2020-09-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.