BNG Reference#
Provides functionality to manipulate British National Grid (BNG) references.
BNGReference Object#
The BNG index system uses BNG references, also known more simply as grid or tile references, to identify and index locations across Great Britain (GB) into grid squares at various resolutions.
The BNGReference object is a custom class that
encapsulates a BNG reference string, providing properties and methods to access
and manipulate the reference.
British National Grid Index System#
The Ordnance Survey (OS) BNG index system, also known as the OS National Grid, is a
rectangular Cartesian 700 x 1300km grid system based upon the transverse Mercator
projection. In the BNG, locations are specified using coordinates, eastings (x) and
northings (y), measured in meters from a defined origin point (0, 0) southwest of
the Isles of Scilly off the coast of Cornwall, England. Values increase to the
northeast, covering all of mainland GB and surrounding islands.
The BNG is structured using a hierarchical system of grid squares at various resolutions. At its highest level, the grid divides GB into 100km by 100km squares, each identified by a two-letter code. Successive levels of resolution further subdivide the grid squares into finer detail, down to individual 1-meter squares.
BNG Reference Structure#
Each BNG reference string consists of a series of alphanumeric characters that encode the easting and northing at a given resolution.
A BNG reference includes a 2-letter prefix that identifies the 100km grid square. This
is followed by an easting and northing value, and optionally, a suffix indicating an
ordinal (intercardinal) direction (NE, SE, SW, NW). These suffixes
represent a quadtree subdivision of the grid at the ‘standard’ resolutions (100km,
10km, 1km, 100m, and 10m), with each direction indicating a specific
quadrant.:
<prefix><easting value><northing value><suffix>
There are two exceptions to this structure:
At the 100km resolution, a BNG reference consists only of the prefix.
At the 50km resolution, a BNG reference includes the prefix and the ordinal direction suffix but does not include easting or northing components.
A BNG reference can be expressed at different scales, as follows:
Resolution |
Description |
Example |
|---|---|---|
100km |
Identified by a two-letter code |
TQ |
50km |
Subdivides the 100km grid into four quadrants. The grid reference adds an ordinal direction suffix (NE, NW, SE, SW) to indicate the quadrant within the 100km square. |
TQ SW |
10km |
Adds one-digit easting and northing values |
TQ 2 3 |
5km |
Subdivides the 10km square adding an ordinal suffix |
TQ 23 SW |
1km |
Adds two-digit easting and northing values |
TQ 23 34 |
500m |
Subdivides the 1km square adding an ordinal suffix |
TQ 23 34 NE |
100m |
Adds three-digit easting and northing values |
TQ 238 347 |
50m |
Subdivides the 100m square adding an ordinal suffix |
TQ 238 347 SE |
10m |
Adds four-digit easting and northing values |
TQ 2386 3472 |
5m |
Subdivides the 10m square adding an ordinal suffix |
TQ 2386 3472 NW |
1m |
Adds five-digit easting and northing values |
TQ 23863 34729 |
BNG Reference Formatting#
BNG reference strings passed to a BNGReference object must
adhere to the following format:
Whitespace may or may not separate the components of the reference (i.e. between the two-letter 100km grid square prefix, easting, northing, and ordinal suffix).
If whitespace is present, it should be a single space character.
Whitespace can be inconsistently used between components of the reference.
The two-letter 100km grid square prefixes and ordinal direction suffixes (
NE,SE,SW,NW) should be capitalised.
EPSG:27700 (OSGB36 / British National Grid)#
The BNG system is a practical application of the EPSG:27700 (OSGB36 / British National Grid) coordinate reference system which provides the geodetic framework that defines how locations defined by easting and northing coordinates and encoded as BNG references (e.g. ‘ST 569 714’) are projected to the grid.
BNG Reference Application#
The BNG index system is widely used by the geospatial community across GB. At each resolution, a given location can be identified with increasing detail, allowing for variable accuracy depending on the geospatial application, from small-scale mapping to precise survey measurements.
BNGReference#
The BNGReference class supports the conversion of 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.
These functions are available both as instance methods of the class and as standalone functions, providing users with the flexibility to either:
Create a
BNGReferenceobject and pass it to a function.Create a
BNGReferenceobject and use one of its instance methods.
BNGReference objects can be compared and ordered. Ordering considers both the grid
resolution and the reference string. They are also hashable, so can be used as
keys or set elements.
- class osbng.bng_reference.BNGReference(bng_ref_string: str)[source]#
Initialises a
BNGReferencefrom a BNG reference string.
Properties#
The BNG reference string of this |
|
The BNG reference string of this |
|
The resolution of this |
|
The resolution of this |
|
A GeoJSON-like mapping of this |
Methods#
|
Returns easting and northing coordinates of this |
Returns grid square bounding box coordinates of this |
|
Returns a grid square as a |
|
|
Returns a list of child |
|
Returns the |
|
Returns a hollow ring of BNGReference objects around this |
|
Returns a filled disc of BNGReference objects around this |
|
Returns the euclidean distance between bng_ref2 and this |
Returns the four BNGReference object neighbours to this BNGReference. |
|
|
Tests whether |
Returns all BNGReference objects within distance |
|
|
Determines whether this |
|
Determines whether this |
Returns a hash value of this |
|
Returns the string representation of this |