spDistsN1: Euclidean or Great Circle distance between points

Description Usage Arguments Details Value Note

View source: R/spDistsN1.R

Description

The function returns a vector of distances between a single 2D point (pts_x, pts_y) and a set of 2D points, provided as two double vectors, pts_x and pts_y.

The distance calculation can be either the Great Circle distance (WGS84 ellipsoid, longlat = TRUE), or the Euclidean distance (longlat = FALSE).

Usage

1
spDistsN1(pt_x, pt_y, pts_x, pts_y, longlat = TRUE)

Arguments

pt_x

A double scalar, the longitude of the single point.

pt_y

A double scalar, the latitude of the single point.

pts_x

A double vector, the longitude of the set of the other points.

pts_y

A double vector, the latitude of the set of the other points.

longlat

A logical scalar indicating whether to calculate the Great Circle (WGS84 ellipsoid) distance (TRUE) or the Euclidean distance (FALSE).

Details

This function is a thin R wrapper around the C function fishy_dists. This function performs no checking on the input, and arguments are passed down to the C implementation as is. This means you should not use this function if you do not know what you are doing.

Value

A double vector of distances in the original metric of the points.

Note

The code is based on the source of sp::spDistsN1. We adapted and included sp::spDistsN1 in this package because of two reasons: (i) to avoid a dependency to sp, as this is the only function used from that package; and (ii) to adapt its prototype to accept vectors instead of matrices, as that fitted better in our workflow.


ramiromagno/fishy documentation built on Feb. 18, 2022, 9 a.m.