Identify neighbouring grid squares
bng_neighbours.Rd
Find BNG references which share a grid cell edge with a target BNG reference.
Arguments
- bng_ref
target object of type
BNGReference
- ...
additional parameters. Not currently used
- bng_ref1, bng_ref2
BNGReference
objects for comparison when assessing neighbour relationships.
Value
A list containing a set of up to four BNGReference
objects
that border the target reference.
a boolean identifying if the grid references share a border
Details
Grid references are "neighbours" when they share a contiguous
edge (i.e. corners do not define neighbours). In the event that a target
reference is along the edge or corner of the valid BNG area, then 3 or 2
references, respectively, will be returned bng_is_neighbour
only
compares references of equal resolution.
If bng_ref1
exactly matches bng_ref2
then
bng_is_neighbour
returns FALSE
.
Examples
bng_neighbours(as_bng_reference("SU1234"))
#> [[1]]
#> <BNGReference[4] with Resolution=1km>
#> [1] <SU 12 33> <SU 11 34> <SU 13 34> <SU 12 35>
#>
bng_is_neighbour(as_bng_reference("SE1921"), as_bng_reference("SE1821"))
#> [1] TRUE
bng_is_neighbour(as_bng_reference("SE1922"), as_bng_reference("SE1821"))
#> [1] FALSE
bng_is_neighbour(as_bng_reference("SU1234"), as_bng_reference("SU1234"))
#> [1] FALSE