Insights

The British National Grid - now in Python and R

A 90year-old legacy infrastructure that still remains relevant today

| 7 minute read
OS has released open‑source tools to use British National Grid (BNG) in your own workflows. Our OS experts – Steve Kingston (Senior Data Scientist), leading a team with Chris Jochem, Tom Peterken, and Kate New (Data Scientists) – provide an overview of the British National Grid, plus help and resources so you can get started making the most of these new data packages.

As of 2026, the British National Grid (BNG) has been supporting mapping and location data across Great Britain, for 90 years!

To keep that legacy going, and support the next generations of BNG adoption, OS has released open‑source tools that enable you to use the BNG as a modern spatial indexing system:

osbng (Python) and osbng (R).

These packages allow you to index your data using the BNG, to work consistently across datasets, and to embed BNG into your existing, analytical pipelines. They’re designed to be accessible to developers, offering tools to simplify working with the BNG, facilitating both technical integration into geospatial workflows, and practical exploration of the index system's structure.

We prioritised Python and R, due to their widespread use across data science, research, government and public sector analytics. We recognised that these tools are designed for real‑world scale, not just experimentation.

The BNG is almost a century old, but its square indexing logic beats modern global indices (like Uber’s H3 and Google’s S2) for GB-centric, multimodal analytics, making national-scale spatial workloads simple, fast, and parallel.

It’s a 1930s idea, solving 2026 problems.

What is the British National Grid?

The BNG is an index system, which is a practical application of the BNG (EPSG:27700) coordinate reference system.

It emerged in the 1930s, designed specifically for Great Britain. At the time, OS mapping was still organised around county‑based sheets, with inconsistent reference systems. Data didn’t line up cleanly across boundaries, limiting national analysis and operational use.

In 1935, the Davidson Committee was established to modernise Britain’s mapping infrastructure. With the Second World War looming, the need for a coherent, scalable system became urgent.

The committee’s recommendations shaped BNG as we still know it today, 90 years later. A unified National Grid: a single projected coordinate system that has full coverage of Great Britain.

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. The BNG divides the country into a hierarchy of grid cells each identified by a unique reference. 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.

As it was built as a hierarchical structure, the BNG could be scaled over time. It also involved moving from imperial units of measurement (inches, feet, acres) to metric units (metres, kilometres) – considered a radical decision at the time!

The end result was a system designed for twentieth‑century mapping, that happened to be robust enough to remain relevant and effective in the twenty‑first. As an example, almost all OS data, plus significant public sector geospatial data, is referenced to OSGB36 / British National Grid.

© Crown copyright and database rights. Ordnance Survey 2026
BNG in 100km, 10km, and 1km squares.

Coordinates to grid indexing

The BNG began as a coordinate system, but it has evolved into a grid indexing framework for geospatial data. What is grid indexing?

Grid indexing means converting spatial data into fixed grid cells, and referring to those cells using simple identifiers, rather than complex geometries.

This has several advantages:

  • Uniform spatial units - Every grid cell is the same size, making analysis consistent.
  • Stability over time - Unlike administrative boundaries, grid cells don’t change.
  • Compatibility with other geographies - Grid indexing works alongside administrative and statistical boundaries, not instead of them.
  • Unbiased spatial partitioning - Grids aren’t influenced by population, politics, or services.

While any arbitrary grid can be used (triangular, square, hexagonal), a nationally defined, standard grid unlocks much greater interoperability.

Grid indexing enables:

Simpler data handling
Spatial features can be reduced to grid IDs, streamlining storage and processing.

Efficient aggregation
Data can be grouped by grid cell to calculate summary statistics quickly and consistently.

Clear spatial visualisation
Grid‑based heatmaps and surfaces reveal spatial patterns cleanly.

Interoperability and data joining
Multiple datasets can use the same grid system. The BNG offers a shared spatial language for Great Britain.

As an example, the above image illustrates one of the key functions in the software: finding all the grid squares that completely cover a geometry (in this case, London) at a specified resolution.

This function works for coordinates, bounding boxes, and, as shown, a feature's geometry. The text in each grid square is the BNG reference at each 5km resolution grid square.

In this next image above, we show how BNG enables indexing of a complicated geometry - using the London region again. Identifying core (ie fully contained) and non-core BNG tiles is an important step for improving the performance of spatial joins, and other operations.

Geospatial insight for Great Britain

For anyone working in Britain-focused data and analytics, BNG has its advantages over other, global grids such as Uber’s H3 and Google’s S2 systems designed for worldwide coverage.

BNG is GB‑centric by design, which minimises distortion across the country. Most authoritative geospatial data in Great Britain already uses BNG, and its square geometry aligns naturally with raster imagery, elevation models, and gridded environmental data.

Its metric units of measurement make distance and area calculations intuitive, and being dense and scalable, it supports everything from national mapping down to street‑level detail.

BNG is also widely understood across government, infrastructure, environment, and utilities. By using BNG, you’ll be speaking the same geospatial language as so many sectors and industries across the country.

How to use it

osbng for Python is available on PyPI, and osbng for R is available on CRAN. After installation, you can use the grid-based indexing to support workflows such as statistical aggregation and data visualisation.

As an example, the below code snippet shows you how to index OS Open UPRN easting and northing coordinates within the London bounding box to 1 km BNG references, then count Unique Property Reference Numbers (UPRNs) in each grid square.

The image (left) is a visualisation of that analysis. 

Whether your organisation is based in local government, land and property, logistics, and many other sectors, here you can see the distribution of UPRNs in a given area, to help with property analysis, addressing, asset management, and much more.

Python

import osbng

import pandas as pd



dtypes = {"UPRN": "int64",

"X_COORDINATE": "float32",

"Y_COORDINATE": "float32"}

# Read OS Open UPRN CSV file with specified data types and column subset

df = pd.read_csv("osopenuprn_202604.csv",

usecols=["UPRN", "X_COORDINATE", "Y_COORDINATE"],

dtype=dtypes)



# London bounding box in British National Grid (EPSG:27700)

filter = (

df["X_COORDINATE"].between(503572, 561958) &

df["Y_COORDINATE"].between(155854, 200934)

)

# Apply the spatial filter to the DataFrame

filtered = df.loc[filter]



# Index easting and northing coordinates to 1km BNG grid reference

filtered["bng_ref"] = filtered.apply(lambda row: osbng.xy_to_bng(easting=row["X_COORDINATE"], northing=row["Y_COORDINATE"], resolution="1km"), axis=1)



# Group by BNG grid reference and count the number of UPRNs in each grid square

grouped = filtered.groupby("bng_ref").size().reset_index(name="count")

R

library(osbng)

library(dplyr) # optional library for data manipulation



# Read OS Open UPRN CSV file

df <- read.csv('osopenuprn_202604.csv')



# Filter to Londong bounding box in British National Grid (EPSG:27700)

df <- df |>

filter(between(X_COORDINATE, 503572, 561958),

between(Y_COORDINATE, 155854, 200934))



# Index easting and northing coordinates to 1km BNG grid reference

df$bng_ref <- xy_to_bng(df$X_COORDINATE,

df$Y_COORDINATE,

resolution = "1km")



# Group by BNG grid reference and count the number of UPRNs in each grid square

grouped = df |>

group_by(bng_ref) |>

summarise(count = n())

This is just one example of many more in how BNG can be used for your analytics – read on to access helpful resources, and discover what else you can do.

A shared spatial language for Britain

As the geospatial community increasingly looks for standardised, interoperable ways to work with location data, to better optimise cross-collaboration and unlock new insight, we’re pleased to provide these libraries.

Built on rich, geospatial heritage, even 90 years later the BNG remains relevant: a legacy infrastructure, that quietly future‑proofed itself in the background!

And there’s more to come, including raster indexing to align vector data with imagery and other sensed data in the same index space. OS also plans to release an Apache Spark UDF wrapper to enable distributed cloud processing support.

Try it for yourself! Click below to access our supporting resources, which explain how to get started, and apply BNG indexing in practice:


Ordnance Survey
By Ordnance Survey

Our highly accurate geospatial data and printed maps help individuals, governments and companies to understand the world, both in Britain and overseas.

Find more Insights

  • Products and services
  • Announcements
  • Developers