osbng.bng_reference.BNGReference.bng_to_parent#
- BNGReference.bng_to_parent(*, resolution: int | str | None = None) BNGReference[source]#
Returns the
BNGReferencethat is the parent of thisBNGReference.By default, the parent of the
BNGReferenceobject is defined as theBNGReferencein the next BNG resolution up from the currentBNGReferenceresolution. For example, 50km -> 100km.Notes
Any valid resolution can be provided as the parent resolution, provided it is greater than the resolution of the current
BNGReferenceobject.- Keyword Arguments:
resolution (int | str | None, optional) – The resolution of the parent
BNGReferenceobjects expressed either as a metre-based integer or as a string label. Defaults to None.- Returns:
- A
BNGReferenceobject that is the parent of the current
BNGReferenceobject.
- A
- Return type:
- Raises:
BNGHierarchyError – If the resolution of the current
BNGReferenceobject is 100km.BNGHierarchyError – If the resolution is less than or equal to the resolution of the current
BNGReferenceobject.BNGResolutionError – If an invalid resolution is provided.
Examples
>>> BNGReference("SU 3 6 SW").bng_to_parent() BNGReference(bng_ref_formatted=SU 3 6, resolution_label=10km) >>> BNGReference("SU 342 567").bng_to_parent() BNGReference(bng_ref_formatted=SU 34 56 NW, resolution_label=500m) >>> BNGReference("SU 342 567").bng_to_parent(resolution=10000) BNGReference(bng_ref_formatted=SU 3 5, resolution_label=10km)
See also
The equivalent
osbng.hierarchy.bng_to_parent()function.