sgo_ngr_bng {sgo}R Documentation

NGR to BNG Easting/Northing

Description

Converts OS National Grid References to Easting/Northing coordinates

Usage

sgo_ngr_bng(x, col = NULL, check.only = FALSE)

Arguments

x

A data.frame, list or vector containing strings describing OS National Grid References, with or without whitespace separators. (e.g. 'SU 387 148').

col

Character string with the name of the 'column' containing the vector of NGR values, it is required when x is a list or data.frame with more than one column.

check.only

Logical parameter. If it is set to TRUE then the routine returns a logical vector indicating which references are correct.

Details

All entered standard grid references can range from two-digit references up to 10-digit references (1m × 1m square). If x is a list with 2 or more vector elements, col can be used to inform the function which of the elements contains the NGR strings. The rest of the elements will be appended to the resulting object. See examples.

Value

An object of class sgo_points whose coordinates are defined as Easting/Northing when check.only is kept as FALSE. Otherwise, it returns a logical vector indicating which grid references are correct and which ones are not.

See Also

sgo_points, sgo_bng_ngr.

Examples

vec <- c("NN 166 712", "HU38637653")
lst <- list(vec)
v <- sgo_ngr_bng(vec)
l <- sgo_ngr_bng(lst)

# any additional column (here 'attr') will be added to the result
extra <- list(p=c("NN 166712", "HU38637653"),
              attr=c("name1","name2"))
res <- sgo_ngr_bng(extra, col="p")
res

# grid references returned by sgo_bng_ngr are within an
# element (column) named 'ngr'
grid <- sgo_bng_ngr(sgo_points(list(x=247455, y=706338, name="Ben Venue"),
                               coords=c("x","y"),
                               epsg=27700))
bng <- sgo_ngr_bng(grid, col="ngr")

# test
bad <- c("NN 166 712", "AA 3863 7653")
check <- sgo_ngr_bng(bad, check.only=TRUE) #returns a logical vector

[Package sgo version 0.9.2 Index]