sp_length: Function to find a spatial object's length in metres or...

View source: R/sp_length.R

sp_lengthR Documentation

Function to find a spatial object's length in metres or kilometres.

Description

sp_length is a wrapper for rgeos::gLength and calculates the lengths of spatial lines or polygons. If sp_length is used with polygons, it returns the length of the perimeter of the polygons.

Usage

sp_length(sp, unit = "m", features = TRUE)

Arguments

sp

Spatial object.

unit

Distance unit to use.

features

Should the function be applied to all features in sp?

Details

The trigonometric function, geosphere::perimeter performs poorly for length calculations. Therefore, when spatial objects are used with sp_length which have projection systems without metre units (such as WGS84), the Mollweide projection system is used by default. The Mollweide projection is applicable in any location on Earth, but the accuracy of the returned values is dependent on location.

If the spatial objects are located in a zone which has a more appropriate projection system, it is highly recommended that this is used. For example, spatial data in New Zealand should be projected in the New Zealand Transverse Mercator 2000 while data in the UK should be projected in British National Grid; both of which have metre units (+units=m).

Author(s)

Stuart K. Grange


skgrange/gissr documentation built on Feb. 24, 2024, 2:55 p.m.