This function converts a grid reference to its square polygon geometry feature through conversion to well-known text.

gridsquare_geometry(x)

# S3 method for gridref
gridsquare_geometry(grid_reference)

Arguments

grid_reference

A Great British or Irish grid reference character string with class gridref.

Value

The square polygon geometry feature

Details

It can check either British or Irish grid references up to 10 figure (1m precision), including tetrads (2000m precision).

See also

Other grid reference functions: easting(), hectad(), hectare(), monad(), northing(), pentad(), precision(), projection(), tetrad()

Examples

suppressPackageStartupMessages({ library(store) suppressWarnings({ library(dplyr) library(janitor) }) }) grid_references <- nbn_demonstration_dataset %>% clean_names() %>% slice_tail(n = 15) %>% select(grid_reference) %>% mutate(grid_reference = as_gridref(grid_reference)) # create sf data frame suppressPackageStartupMessages({ suppressWarnings({ library(dplyr) library(sf) }) }) grid_references %>% rowwise() %>% mutate(geometry = gridsquare_geometry(grid_reference)) %>% st_as_sf()
#> Simple feature collection with 15 features and 1 field #> Geometry type: POLYGON #> Dimension: XY #> Bounding box: xmin: 522600 ymin: 283240 xmax: 524000 ymax: 286000 #> Projected CRS: OSGB 1936 / British National Grid #> # A tibble: 15 x 2 #> # Rowwise: #> grid_reference geometry #> <gridref> <POLYGON [m]> #> 1 TL2384 ((523000 284000, 524000 284000, 524000 285000, 523000 285000,~ #> 2 TL232839 ((523200 283900, 523300 283900, 523300 284000, 523200 284000,~ #> 3 TL2385 ((523000 285000, 524000 285000, 524000 286000, 523000 286000,~ #> 4 TL231840 ((523100 284000, 523200 284000, 523200 284100, 523100 284100,~ #> 5 TL232839 ((523200 283900, 523300 283900, 523300 284000, 523200 284000,~ #> 6 TL23248346 ((523240 283460, 523250 283460, 523250 283470, 523240 283470,~ #> 7 TL23568493 ((523560 284930, 523570 284930, 523570 284940, 523560 284940,~ #> 8 TL23448505 ((523440 285050, 523450 285050, 523450 285060, 523440 285060,~ #> 9 TL23128324 ((523120 283240, 523130 283240, 523130 283250, 523120 283250,~ #> 10 TL234850 ((523400 285000, 523500 285000, 523500 285100, 523400 285100,~ #> 11 TL234846 ((523400 284600, 523500 284600, 523500 284700, 523400 284700,~ #> 12 TL232839 ((523200 283900, 523300 283900, 523300 284000, 523200 284000,~ #> 13 TL231841 ((523100 284100, 523200 284100, 523200 284200, 523100 284200,~ #> 14 TL226846 ((522600 284600, 522700 284600, 522700 284700, 522600 284700,~ #> 15 TL2384 ((523000 284000, 524000 284000, 524000 285000, 523000 285000,~