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.

  • 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, 10000, or 100000. Overrides digits.

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 = " ")

[Package igr version 0.1.1 Index]