osbng.bng_reference.BNGReference.bng_distance#
- BNGReference.bng_distance(bng_ref2: BNGReference, *, edge_to_edge: bool = False) float[source]#
Returns the euclidean distance between bng_ref2 and this
BNGReference.When
edge_to_edgeis False, the distance is the centroid-to-centroid distance in metres. Whenedge_to_edgeis True, the distance is the shortest distance between any two parts of the grid squares.Notes
The other
BNGReferenceobject does not necessarily need to share a common resolution. Whenedge_to_edge= True and the twoBNGReferenceobjects have a parent-child relationship, the returned distance is 0.- Parameters:
bng_ref2 (BNGReference) – A
BNGReferenceobject .- Keyword Arguments:
edge_to_edge (bool, optional) – If False (default), distance will be centroid-to-centroid distance. If True, distance will be the shortest distance between any point in the grid squares.
- Returns:
The euclidean distance between the centroids of the two
BNGReferenceobjects.- Return type:
- Raises:
TypeError – If the
bng_ref2argument is not a
Examples
>>> BNGReference("SE1433").bng_distance(BNGReference("SE1533")) 1000.0 >>> BNGReference("SE1433").bng_distance( ... BNGReference("SE1533"), edge_to_edge=True ... ) 0.0 >>> BNGReference("SE1433").bng_distance(BNGRerence("SE1631")) 2828.42712474619 >>> BNGReference("SE1433").bng_distance(BNGRerence("SE")) 39147.158262126766 >>> BNGReference("SE1433").bng_distance(BNGRerence("SENW")) 42807.709586007986 >>> BNGReference("SE").bng_distance(BNGRerence("OV")) 141421.35623730952 >>> BNGReference("SU").bng_distance( ... BNGReference("SU2345"), edge_to_edge=True ... ) 0.0
See also
The equivalent
osbng.traversal.bng_distance()function.