bng_to_geom {osdatahub}R Documentation

Return the geometry of a British National Grid square

Description

Convert a valid British National Grid (BNG) grid reference string into a grid square with the resolution implied by the length of the reference string.

Usage

bng_to_geom(grid_ref, returnType = c("wkt", "geojson", "geos", "sf"))

Arguments

grid_ref

(character) BNG grid reference (required).

returnType

(character) Representation for the returned geometry. Choose 'wkt' or 'geojson' to return the geometry in Well-Known Text format or GeoJSON, respectively, 'geos' to return an object of class geos or 'sf' for a Simple Features object of class sf. Default is WKT format.

Details

The National Grid is a unique reference system that covers Great Britain in a series of grid squares at multiple scales. Grid references begin with 2 letters to identify 100km squares followed by a series of digits to identify quadrants nested within. For more information, see https://www.ordnancesurvey.co.uk/documents/resources/guide-to-nationalgrid.pdf

The purpose of this function is to generate geometries based on the extent of the grid square which can be used as spatial filters in OS Data Hub API queries.

Note that all geometries returned will have a coordinate reference system (CRS) of a EPSG:27700. The sf package must be installed in order to return an object of class sf.

Value

The coordinates of the grid square boundary in either Well-Known Text (WKT) format, GeoJSON format, an object of class geos or as a Simple Features object of class sf.

See Also

extent_from_bng()

Examples

bng_to_geom('TL63')
bng_to_geom('TL683365', returnType = 'geojson')


[Package osdatahub version 0.2.0 Index]