furdist: Distance to the furthest location on a geometry

furdistR Documentation

Distance to the furthest location on a geometry

Description

For each point in x, compute the distance to the furthest location on the edge of the geometries in y. This is the counterpart of distance, which returns the distance to the nearest location.

The "edge" is the boundary of polygons, the line itself for lines, and the points for a points geometry.

Usage

## S4 method for signature 'SpatVector,SpatVector'
furdist(x, y, pairwise=FALSE, unit="m")

Arguments

x

SpatVector of points. The location(s) from which the distance is measured

y

SpatVector of points, lines, or polygons. The geometries whose furthest edge location is measured

pairwise

logical. If TRUE and if x and y have the same number of geometries (or one of them has a single geometry), the pairwise distances (point i of x with geometry i of y) are returned. If FALSE, the distances for all combinations are returned

unit

character. Can be either "m" or "km"

Value

If pairwise=TRUE a numeric vector with one distance for each pair. Otherwise a data.frame with columns "from" (the index of the point in x), "to" (the index of the geometry in y) and "distance".

See Also

distance, nearest, snapTo

Examples

# planar
crs <- "+proj=utm +zone=1"
p <- vect("POLYGON ((0 0, 8 0, 8 9, 0 9, 0 0))", crs=crs)
pts <- vect(cbind(c(1, 5), c(1, 5)), crs=crs)

furdist(pts, p)
furdist(pts, p, unit="km")

# longitude/latitude
pp <- vect("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))", crs="lonlat")
q <- vect(cbind(5, 5), crs="lonlat")
furdist(q, pp, unit="km")

terra documentation built on Aug. 22, 2026, 5:07 p.m.