Learn R Programming

rdwd (version 1.8.0)

lldist: distance between lat-long coordinates

Description

Great-circle distance between points at lat-long coordinates. Mostly a copy of OSMscale::earthDist Version 0.5.3 (2017-04-19). https://github.com/brry/OSMscale/blob/master/R/earthDist.R#L57-L102. Copied manually to avoid dependency hell. Does not check coordinates. Not exported.

Usage

lldist(lat, long, data, r = 6371, i = 1L)

maxlldist(lat, long, data, r = 6371, fun = max, each = TRUE, ...)

Value

Vector with distance(s) in km (or units of r, if r is changed)

Arguments

lat, long

Latitude (North/South) and longitude (East/West) coordinates in decimal degrees

data

Optional: data.frame with the columns lat and long

r

radius of the earth. Could be given in miles. DEFAULT: 6371 (km)

i

Integer: Index element against which all coordinate pairs are computed. DEFAULT: 1

fun

Function to be applied. DEFAULT: max()

each

Logical: give max dist to all other points for each point separately? If FALSE, will return the maximum of the complete distance matrix, as if max(maxlldist(y,x)). For examples, see OSMscale::maxEarthDist DEFAULT: TRUE

...

Further arguments passed to fun, like na.rm=TRUE

Author

Berry Boessenkool, berry-b@gmx.de, Aug 2016 + Jan 2017. Angle formula from Diercke Weltatlas 1996, Page 245