Convert BNG References
bng_to_xy.Rd
Create British National Grid references from coordinates at a specific resolution or convert grid reference objects to coordinates at a grid position.
Usage
bng_to_xy(
bng_ref,
position = c("lower-left", "upper-left", "upper-right", "lower-right", "centre"),
...
)
xy_to_bng(...)
# S3 method for numeric
xy_to_bng(easting, northing, resolution, ...)
# S3 method for matrix
xy_to_bng(x, resolution, ...)
# S3 method for data.frame
xy_to_bng(df, cols = c("eastings", "northings"), resolution, ...)
Arguments
- bng_ref
vector of type
BNGReference
objects- position
character indicating which point location of the BNG grid square is returned. Default is the lower-left corner.
- ...
additional parameters, not currently used
- easting
numeric vector of coordinates
- northing
numeric vector of coordinates
- resolution
target BNG grid resolution. Can be specified as a numeric or character vector
- x
two column matrix of eastings and northings
- df
data.frame with columns of coordinates to convert
- cols
column names or indices within
df
holding coordinates
Value
xy_to_bng
: vector ofBNGReference
objectsbng_to_xy
: two-column matrix of eastings and northings
Details
Coordinates must be in British National Grid projection (EPSG:27700) using eastings and northings in meters. These functions do not support coordinate transformations.
Examples
bng_to_xy(as_bng_reference("SU"), "lower-left")
#> [,1] [,2]
#> [1,] 4e+05 1e+05
bng_to_xy(as_bng_reference("SU 3 1"), "lower-left")
#> [,1] [,2]
#> [1,] 430000 110000
bng_to_xy(as_bng_reference("SU 3 1 NE"), "centre")
#> [,1] [,2]
#> [1,] 437500 117500
bng_to_xy(as_bng_reference("SU 37289 15541"), "centre")
#> [,1] [,2]
#> [1,] 437289.5 115541.5
xy_to_bng(437289, 115541, "100km")
#> <BNGReference[1] with Resolution=100km>
#> [1] <SU>
xy_to_bng(437289, 115541, "10km")
#> <BNGReference[1] with Resolution=10km>
#> [1] <SU 3 1>
xy_to_bng(437289, 115541, "5km")
#> <BNGReference[1] with Resolution=5km>
#> [1] <SU 3 1 NE>
xy_to_bng(437289, 115541, 1)
#> <BNGReference[1] with Resolution=1m>
#> [1] <SU 37289 15541>
# example code
# example code