gridsquare_geometry: Convert a OSGB or OSNI grid reference to a polygon geometry...

View source: R/gridref.R

gridsquare_geometryR Documentation

Convert a OSGB or OSNI grid reference to a polygon geometry feature

Description

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

Usage

gridsquare_geometry(x)

## S3 method for class 'gridref'
gridsquare_geometry(grid_reference)

Arguments

grid_reference

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

Details

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

Value

The square polygon geometry feature

See Also

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

Examples

 suppressPackageStartupMessages({
   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()

gcfrench/store documentation built on May 17, 2024, 5:52 p.m.