Description Usage Arguments Details Value Author(s) See Also Examples

An all-R routine that computes total length of all
lines in a `SpatialLines*`

object.

1 | ```
lineLength(x, byid = FALSE)
``` |

`x` |
A spatial object inheriting from |

`byid` |
Whether to return lengths of individual spatial objects (TRUE) or the sum of all length (FALSE). |

Provides the same answer as `rgeos::gLength`

, but is
all-R (does not require rgeos Java library) and does not
fire a warning if `x`

is un-projected (i.e., lat-long).

If `byid==TRUE`

, a vector containing the lengths of individual
spatial objects
(the points, lines, or polygons) is returned. If `byid=FALSE`

,
the total length of all spatial objects is returned (a single number).

If `x`

inherits from `SpatialPoints`

, returned
value is 0. If `x`

inherits from `SpatialLines`

, returned
value contains line lengths or the sum of line lengths in `x`

.
If `x`

inherits from `SpatialPolygons`

, returned
value contains lengths of the perimeter of all polygons, or
the sum of perimeters, in `x`

. When `x`

contains polygons with
holes, the perimeter of the holes is included (i.e., perimeter of holes
is positive, not negative).

Units of the returned value are same as units of coordinates
in `x`

. E.g.,
meters if coordinates in `x`

are UTM meters,
decimal degrees if coordinates in `x`

are lat-long decimal
degrees.

Trent McDonald

1 2 | ```
# Length of Hawaii coastline, in kilometers
l <- lineLength( HI.coast ) / 1000
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.