osbng.grids.bbox_to_bng_iterfeatures#

osbng.grids.bbox_to_bng_iterfeatures(xmin: int | float, ymin: int | float, xmax: int | float, ymax: int | float, resolution: int | str) Iterator[dict[str, Any]][source]#

Returns an iterator of BNGReference Features given a bounding box and resolution.

Implements the __geo_interface__ protocol. The returned data structure represents the BNGReference object as a GeoJSON-like Feature.

Parameters:
  • xmin (int | float) – The minimum easting coordinate of the bounding box (BBOX).

  • ymin (int | float) – The minimum northing coordinate of the BBOX.

  • xmax (int | float) – The maximum easting coordinate of the BBOX.

  • ymax (int | float) – The maximum northing coordinate of the BBOX.

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

Yields:

dict[str, Any] – A GeoJSON-like representation of a BNGReference object.

Raises:

BNGResolutionError – If the resolution is not a valid resolution.

Examples

>>> print(*bbox_to_bng_iterfeatures(530000, 180000, 535000, 185000, "5km"))
{'type': 'Feature', 'properties': {'bng_ref': 'TQ38SW'}, 'geometry':
{'type': 'Polygon', 'coordinates': (((535000.0, 180000.0), (535000.0, 185000.0),
(530000.0, 185000.0), (530000.0, 180000.0), (535000.0, 180000.0)),)}}
>>> print(*bbox_to_bng_iterfeatures(530000, 180000, 535000, 185000, "10km"))
{'type': 'Feature', 'properties': {'bng_ref': 'TQ38'}, 'geometry':
{'type': 'Polygon', 'coordinates': (((540000.0, 180000.0), (540000.0, 190000.0),
(530000.0, 190000.0), (530000.0, 180000.0), (540000.0, 180000.0)),)}}