igr_to_ig()
converts Irish grid references into a list of Irish Grid
(EPSG:29903) X and Y coordinates. By default the coordinates of the south
west corners of each Irish grid reference are calculated. The precision of each
Irish grid reference in metres can be returned.
Usage
igr_to_ig(
x,
coords = c("x", "y"),
centroids = FALSE,
precision = NULL,
tetrad = TRUE
)
Arguments
- x
A character vector of Irish grid references. See
igr_is_valid()
for a definition of valid Irish grid references.- coords
A character vector of the names of the columns to contain the Irish Grid X and Y coordinates respectively.
- centroids
Should the coordinates of the centroids of the Irish grid references be returned (rather than the south west corners)?
- precision
The name of the column to contain the precision of each Irish grid reference in metres, if required.
- tetrad
Permit tetrad form of Irish grid reference?
Value
A list containing Irish Grid X and Y coordinates and, optionally, the precision in metres of each Irish grid reference. Invalid or missing Irish grid references return NA.
Examples
# A vector of Irish grid references of different precisions
v <- c("N8090", "D1234588800", "W34", "", "D12T")
# Convert south west corners of Irish grid references to Irish Grid coordinates
igr_to_ig(v)
#> Warning: Invalid Irish grid references detected:
#> $x
#> [1] 280000 312345 130000 NA 316000
#>
#> $y
#> [1] 290000 488800 40000 NA 426000
#>
# Convert centroids of Irish grid references to Irish Grid coordinates
igr_to_ig(v, centroids = TRUE)
#> Warning: Invalid Irish grid references detected:
#> $x
#> [1] 280500.0 312345.5 135000.0 NA 317000.0
#>
#> $y
#> [1] 290500.0 488800.5 45000.0 NA 427000.0
#>
# Specify column names
igr_to_ig(v, coords = c("e", "n"))
#> Warning: Invalid Irish grid references detected:
#> $e
#> [1] 280000 312345 130000 NA 316000
#>
#> $n
#> [1] 290000 488800 40000 NA 426000
#>
# Also return the precision in metres of each Irish grid reference
igr_to_ig(v, precision = "prec")
#> Warning: Invalid Irish grid references detected:
#> $x
#> [1] 280000 312345 130000 NA 316000
#>
#> $y
#> [1] 290000 488800 40000 NA 426000
#>
#> $prec
#> [1] 1000 1 10000 NA 2000
#>