misc-gLength.Rd
Calculates the length of the given geometry.
gLength(spgeom, byid=FALSE)
sp object as defined in package sp
Logical determining if the function should be applied across subgeometries (TRUE) or the entire object (FALSE)
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).
gLength(readWKT("POINT(1 1)"))
#> [1] 0
gLength(readWKT("LINESTRING(0 0,1 1,2 2)"))
#> [1] 2.828427
gLength(readWKT("LINESTRING(0 0,1 1,2 0,3 1)"))
#> [1] 4.242641
gLength(readWKT("POLYGON((0 0,3 0,3 3,0 3,0 0))"))
#> [1] 12
gLength(readWKT("POLYGON((0 0,3 0,3 3,0 3,0 0),(1 1,2 1,2 2,1 2,1 1))"))
#> [1] 16