Skip to contents

Generate a set of BNG Reference objects given a geometry and a specified resolution and provide results in a spatial data frame format.

Usage

geom_to_bng_intersection_explode(geom, resolution, reset_index = TRUE, ...)

# S3 method for geos_geometry
geom_to_bng_intersection_explode(geom, resolution, reset_index = TRUE, ...)

# S3 method for sf
geom_to_bng_intersection_explode(geom, resolution, reset_index = TRUE, ...)

# S3 method for sfc
geom_to_bng_intersection_explode(geom, resolution, reset_index = TRUE, ...)

Arguments

geom

geometry object of type geos-geometry or sf

resolution

spatial resolution of the BNG cell expressed in string or integer values

reset_index

logical. Should the row names be reset in the output? Default is TRUE to renumber the output rows sequentially.

...

additional parameters. Not currently used.

Value

a spatial data frame of type sf with the coordinate reference system to British National Grid (EPSG:27700). The non-geometry columns of the input (if any) are joined with three columns for the BNGReference object, the is_core property, and the indexed geometry.

Details

The BNG Reference objects returned represent the grid squares intersected by the input geometry. This function followings the pattern of geom_to_bng_intersection(), but flattens the list structure of results into a spatial data frame. The original geometry is dropped in this process and all other columns are retained in the output.

The sf package is required to use this functionality.

Examples

geom_to_bng_intersection_explode(geos::geos_make_polygon(c(375480.64511692, 
426949.67604058, 465166.20199588, 453762.88376729, 393510.2158297, 
375480.64511692), c(144999.23691181, 160255.02751493, 153320.57724078, 
94454.79935802, 91989.21703833, 144999.23691181)), "50km")
#> Simple feature collection with 9 features and 2 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 375480.6 ymin: 91989.22 xmax: 465166.2 ymax: 160255
#> Projected CRS: OSGB 1936 / British National Grid
#>   bng_reference is_core                       geometry
#> 1       <SY NE>   FALSE POLYGON ((393510.2 91989.22...
#> 2       <SZ NW>   FALSE POLYGON ((4e+05 92254.78, 4...
#> 3       <SZ NE>   FALSE POLYGON ((453762.9 94454.8,...
#> 4       <ST SE>   FALSE POLYGON ((392351.9 150000, ...
#> 5       <SU SW>    TRUE POLYGON ((4e+05 1e+05, 4500...
#> 6       <SU SE>   FALSE POLYGON ((454837.1 1e+05, 4...
#> 7       <ST NE>   FALSE POLYGON ((4e+05 152266.9, 4...
#> 8       <SU NW>   FALSE POLYGON ((426949.7 160255, ...
#> 9       <SU NE>   FALSE POLYGON ((465166.2 153320.6...