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 or with empty geometry are returned as NA.
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.
0: equivalent to a precision of 100 km.1: equivalent to a precision of 10 km.2: equivalent to a precision of 1 km.3(the default): equivalent to a precision of 100 m.4: equivalent to a precision of 10 m.5: equivalent to a precision of 1 m.
- precision
An integer, the precision of the Irish grid references in metres:
1,10,100,1000,2000,10000, or100000. Overridesdigits. Use2000to produce the tetrad form of Irish grid reference.- sep
A character string to place between the 100 km grid letter, easting, northing, and tetrad.
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)
#> [1] "A000000" "Z900000"
# Convert into Irish grid references with 4 digit easting and northing (10 m precision)
st_irishgridrefs(x_sf, digits = 4)
#> [1] "A00000000" "Z90000000"
# Convert into Irish grid references with 1 km precision (2 digit easting and northing)
st_irishgridrefs(x_sf, precision = 1000)
#> [1] "A0000" "Z9000"
# Convert into Irish grid references with 2 km precision (tetrad form)
st_irishgridrefs(x_sf, precision = 2000)
#> [1] "A00A" "Z90A"
# Insert a space between the 100 km grid letter, easting, and northing
st_irishgridrefs(x_sf, sep = " ")
#> [1] "A 000 000" "Z 900 000"
