osbng.indexing.xy_to_bng#

osbng.indexing.xy_to_bng(easting: int | float, northing: int | float, resolution: int | str) BNGReference[source]#

Returns a BNGReference given easting and northing coordinates and resolution.

Parameters:
  • easting (int | float) – The easting coordinate.

  • northing (int | float) – The northing coordinate.

  • resolution (int | str) – The BNG resolution expressed either as a metre-based integer or as a string label.

Returns:

The BNGReference.

Return type:

BNGReference

Raises:
  • BNGResolutionError – If an invalid resolution is provided.

  • BNGExtentError – If the easting and northing coordinates are outside the BNG index system extent.

Examples

>>> xy_to_bng(437289, 115541, "100km")
BNGReference(bng_ref_formatted=SU, resolution_label=100km)
>>> xy_to_bng(437289, 115541, "10km")
BNGReference(bng_ref_formatted=SU 3 1, resolution_label=10km)
>>> xy_to_bng(437289, 115541, "5km")
BNGReference(bng_ref_formatted=SU 3 1 NE, resolution_label=5km)
>>> xy_to_bng(437289, 115541, 1)
BNGReference(bng_ref_formatted=SU 37289 15541, resolution_label=1m)

See also

The bng_to_xy() function and osbng.bng_reference.BNGReference.bng_to_xy() instance method for decoding a BNGReference to easting and northing coordinates.