Skip to contents

Convert or test user input (strings) to a custom object for handling British National Grid (BNG) references.

Usage

as_bng_reference(bng_ref, ...)

# S3 method for default
as_bng_reference(bng_ref, ...)

# S3 method for BNGReference
as_bng_reference(bng_ref, ...)

# S3 method for character
as_bng_reference(bng_ref, ...)

is_bng_reference(bng_ref)

Arguments

bng_ref

A character vector of grid references to be created or tested.

...

Additional parameters. Not currently used.

Value

An object of type BNGReference.

Details

Converts a BNG reference string into a BNGReference object, ensuring type consistency across the package. All functions accepting or returning BNG references enforce the use of this class.

The BNG is structured using a hierarchical system of grid squares at various resolutions. At its highest level, the grid is divided into 100 km by 100 km squares, each of which is identified by a two-letter code. Successive levels of resolution further subdivide the grid squares into finer detail, down to individual 1-meter squares.

The package supports the 'standard' and 'intermediate' quadtree resolutions: 100km, 50km, 10km, 5km, 1km, 500m, 100m, 50m, 10m, 5m and 1m.

Examples

as_bng_reference("TQ1234")
#> <BNGReference[1] with Resolution=1km>
#> [1] <TQ 12 34>

as_bng_reference(c("TQ1234", "SU5678"))
#> <BNGReference[2] with Resolution=1km>
#> [1] <TQ 12 34> <SU 56 78>