st_igr_as_sf {igr}R Documentation

Convert a data frame containing Irish grid references into an sf object

Description

st_igr_as_sf() converts a data frame containing Irish grid references into an sf object containing point or polygon features. If points, the south west corners of the grid references are returned. If polygons, squares spanning the full extent of each grid reference are returned, with each square's size depending on the precision of each grid reference. The Irish Grid (EPSG:29903) X and Y coordinates and grid reference precision in metres can also be returned.

Usage

st_igr_as_sf(
  x,
  igrefs = "igr",
  crs = 29903,
  remove = FALSE,
  add_coords = FALSE,
  coords = c("x", "y"),
  precision = NULL,
  polygons = FALSE
)

Arguments

x

A data.frame containing a column of valid Irish grid references. It must not have column names specified in coords.

igrefs

The name or index of the character column holding Irish grid references.

crs

A valid EPSG value (numeric), a string accepted by GDAL, or an object of class crs containing the coordinate reference system to be assigned. See sf::st_crs().

remove

Should the column containing the Irish grid references be removed from the result?

add_coords

Should the Irish Grid coordinates with column names specified by coords be included in the result?

coords

A character vector of the names of the columns to contain the Irish Grid X and Y coordinates respectively.

precision

The name of the column to contain the precision of each Irish grid reference in metres, if required.

polygons

If FALSE (the default) the result will contain point features located at the south-west corner of each Irish grid reference. If TRUE the result will contain polygon features spanning the extent of each Irish grid reference.

Value

An sf object containing point or polygon features for each Irish grid reference in x.

Examples

# A data.frame containing two Irish grid references
x <- data.frame(igr = c("A00", "N8000"))

# Convert a data.frame of Irish grid references to an sf object in the
# Irish Grid coordinate reference system
st_igr_as_sf(x, "igr")

# Convert to an sf object in the WGS 84 coordinate reference system
st_igr_as_sf(x, "igr", crs = 4326)

# Include the Irish Grid coordinates and precision in the sf object
st_igr_as_sf(x, "igr", add_coords = TRUE, precision = "prec")

# Convert into polygon features rather than point features
st_igr_as_sf(x, "igr", polygons = TRUE)


[Package igr version 0.1.1 Index]