bng_distance {osbng} | R Documentation |
Distance calculations
Description
Compute Euclidean distances between BNG references and distance-based neighbours lists.
Usage
bng_dwithin(bng_ref, d, ...)
bng_distance(bng_ref1, bng_ref2, by_element = FALSE, edge_to_edge = FALSE)
Arguments
bng_ref |
object of class |
d |
numeric. Distance expressed in metres. |
... |
additional parameters. Not currently used. |
bng_ref1 , bng_ref2 |
object of |
by_element |
logical. If |
edge_to_edge |
Logical. Should the distances be measured between the
edges of the grid references? Default is |
Details
bng_dwithin
returns all grids squares for which any part of the
boundary is within the distance d
of any part of bng_ref
's
boundary.
Value
list containing an unordered vector of BNGReference
objects
around a given grid square within an absolute distance d
.
If by_element
is FALSE
bng_distance
returns a
dense numeric matrix of dimension length(x) by length(y); otherwise it
returns a numeric vector the same length as x
and y
with an
error raised if the lengths of x
and y
are unequal. Distances
involving invalid references are NA
.
Examples
bng_dwithin(as_bng_reference("SU1234"), 1000)
bng_dwithin(as_bng_reference("SU1234"), 1001)
ref1 <- as_bng_reference("SE1433")
bng_distance(ref1, as_bng_reference("SE1631"))
bng_distance(ref1, as_bng_reference("SENW"))
ref2 <- as_bng_reference(c("SE1533", "SE1631", "SE"))
bng_distance(ref1, ref2)
bng_distance(ref2)
ref3 <- as_bng_reference(c("SE1433", "SE1244"))
bng_distance(ref3, ref2)
bng_distance(ref3, ref2[1:2], by_element = TRUE)
bng_distance(ref1, ref2, edge_to_edge = TRUE)