st_irishgridrefs {igr} | R Documentation |
Generate Irish grid references from an sf object
Description
st_irishgridrefs()
returns the Irish grid references for all features in an
sf object of point geometries. Features located outside the Irish Grid
(EPSG:29903) extent are returned as NA.
Usage
st_irishgridrefs(x, digits = 3, precision = NULL, sep = "")
Arguments
x |
An sf object containing geometries of type POINT. |
digits |
An integer, the number of digits for both easting and northing in the Irish grid references.
|
precision |
An integer, the precision of the Irish grid references in
metres: |
sep |
A character string to separate the 100 km grid letter, easting, and northing. |
Value
A character vector of Irish grid references.
Examples
# An sf object containing point data
x_sf <- sf::st_as_sf(data.frame(x = c(0, 490000), y = c(400000, 0)),
crs = 29903,
coords = c("x", "y")
)
# Convert to Irish grid references
st_irishgridrefs(x_sf)
# Convert into Irish grid references with 4 digit easting and northing (10 m precision)
st_irishgridrefs(x_sf, digits = 4)
# Convert into Irish grid references with 1 km precision (2 digit easting and northing)
st_irishgridrefs(x_sf, precision = 1000)
# Insert a space between the 100 km grid letter, easting, and northing
st_irishgridrefs(x_sf, sep = " ")