geoDist: Distance between Coordinates

View source: R/accessory_geo.R

geoDistR Documentation

Distance between Coordinates

Description

Calculate the distances between geographical coordinates, taking into account that Earth is an oblate spheroid. By default, distances are returned in kilometers. This function is adapted from the function rdist.earth() from package fields.

Usage

geoDist(lon, lat, radius = 6371)

Arguments

lon

numerical. Longitude in decimal degrees

lat

numerical. Latitude in decimal degrees

radius

numerical. Radius in kilometers to find spherical distances. Default to 6371 km. (If 1 distances are returned in radians)

Value

A distance matrix

Author(s)

Renato A. F. de Lima

References

Nychka, D., Furrer, R., Paige, J., Sain, S. (2017). fields: Tools for spatial data. R package version 11.6, <URL: https://github.com/NCAR/Fields>.

Examples


lon <- c(-47, -46, -47)
lat <- c(-23, -24, -23.5)

## Not run: 
geoDist(lon, lat)

## End(Not run)


LimaRAF/plantR documentation built on Jan. 1, 2023, 10:18 a.m.