Learn R Programming

rgeos (version 0.3-22)

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

See Also

gArea

Examples

Run this code
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))"))

Run the code above in your browser using DataLab