georange: georange

georangeR Documentation

georange

Description

Calculate range of distances (min-max) between all points in one or two rectangular objects containing lon-lat coordinates.

Usage

georange(x, y, sequential = FALSE, measure = "cheap")

Arguments

x

Rectangular object (matrix, data.frame, tibble, whatever) containing longitude and latitude coordinates.

y

Optional second object which, if passed, results in distances calculated between each object in x and each in y.

sequential

If TRUE, calculate (vector of) distances sequentially along x (when no y is passed), otherwise calculate matrix of pairwise distances between all points.

measure

One of "haversine" "vincenty", "geodesic", or "cheap" specifying desired method of geodesic distance calculation; see Notes.

Value

A named vector of two numeric values: minimum and maximum, giving the respective distances in metres.

Note

measure = "cheap" denotes the mapbox cheap ruler https://github.com/mapbox/cheap-ruler-cpp; measure = "geodesic" denotes the very accurate geodesic methods given in Karney (2013) "Algorithms for geodesics" J Geod 87:43-55, and as provided by the 'st_dist()' function from the sf package.

Examples

n <- 50
x <- cbind (-10 + 20 * runif (n), -10 + 20 * runif (n))
y <- cbind (-10 + 20 * runif (2 * n), -10 + 20 * runif (2 * n))
colnames (x) <- colnames (y) <- c ("x", "y")
# All of the following returns vector of two values: minimum and maximum:
d0 <- georange (x)
d1 <- georange (x, y)
d2 <- georange (x, sequential = TRUE)
d0_2 <- georange (x, measure = "geodesic") # nanometre-accurate version of d0

geodist documentation built on July 4, 2024, 1:11 a.m.