bbox_to_bng {osbng}R Documentation

Convert bounding boxes

Description

Create British National Grid reference from bounding boxes or convert grid reference objects into bounding boxes.

Usage

bbox_to_bng(...)

## S3 method for class 'numeric'
bbox_to_bng(xmin, ymin, xmax, ymax, resolution, ...)

## S3 method for class 'matrix'
bbox_to_bng(x, resolution, ...)

## S3 method for class 'data.frame'
bbox_to_bng(x, resolution, ...)

bng_to_bbox(bng_ref, ...)

bng_to_grid_geom(bng_ref, format = c("geos", "sf", "wkt"), ...)

Arguments

...

additional parameters, not currently used

xmin, ymin, xmax, ymax

numeric vector of bounding box coordinates

resolution

the resolution of the BNG reference expressed either as a metre-based integer or as a string label

x

optional input of the bounding box as a matrix or data frame of values. Either a numeric vector or object must be supplied.

bng_ref

vector of type BNGReference objects

format

character indicating the type of geometry object to return. Default is "geos" while "sf" returns an object of class sfc.

Details

The relationship between the bounding box and the returned BNG grid squares depends on the alignment of the bounding box with the BNG index system:

If the bounding box edges align with the BNG system (e.g. xmin, ymin, xmax, ymax are multiples of the specified resolution), only the grid squares entirely contained within the bounding box are returned. Grid squares that intersect but are not fully contained within the bounding box are excluded.

If the bounding box edges are not aligned with the BNG system, grid squares that are partially overlapped by the bounding box are also included. In this case, the function ensures all relevant grid squares that the bounding box touches are returned, including those at the edges.

Validates and normalises the bounding box coordinates to the BNG index system extent. If bounding box coordinates fall outside of the BNG system extent, the coordinates are snapped to the bounds of the BNG system.

Bounding boxes are expressed as four coordinates (min x, min y, max x, max y). Coordinates must be in British National Grid projection (EPSG:27700). These functions do not support coordinate transformations.

For matrix input, the first four columns are used as xmin, ymin, xmax, and ymax, respectively. For data.frame input columns must be named "xmin", "ymin", "xmax", and "ymax" or the first columns will be assumed.

To return the BNG grid squares within the bounding box of a geometry, see geom_to_bng().

Value

Examples

bbox_to_bng(400000, 100000, 500000, 200000, "50km")

bbox_to_bng(285137.06, 78633.75, 299851.01, 86427.96, 5000)

bng_to_bbox(as_bng_reference("SU"))

bng_to_bbox(as_bng_reference("SU 3 1"))

bng_to_bbox(as_bng_reference("SU 3 1 NE"))

bng_to_bbox(as_bng_reference("SU 37289 15541"))

bng_to_grid_geom(as_bng_reference("SU"))

bng_to_grid_geom(as_bng_reference("SU 3 1"))

bng_to_grid_geom(as_bng_reference("SU 3 1 NE"))

bng_to_grid_geom(as_bng_reference("SU 37289 15541"))


[Package osbng version 0.2.0 Index]