Skip to contents

Safely compute linestring length in km and return a plain numeric vector.

Usage

add_lengthkm(x)

Arguments

x

An `sf` object with LINE* geometry. If `x` is not in a projected CRS, `sf::st_length()` will compute ellipsoidal lengths when possible.

Value

A numeric vector of lengths in kilometers.

Examples

if (FALSE) { # \dontrun{
fl <- sf::read_sf("hydrofabric.gpkg", "flowpaths")
fl$lengthkm <- add_lengthkm(fl)
} # }