igr
An R Package to convert between Irish grid references and Irish Grid coordinates or an sf object
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.7%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
An R Package to convert between Irish grid references and Irish Grid coordinates or an sf object
Basic Info
- Host: GitHub
- Owner: digitalnature-ie
- License: gpl-3.0
- Language: R
- Default Branch: main
- Homepage: https://digitalnature-ie.github.io/igr/
- Size: 2.91 MB
Statistics
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 2
- Releases: 3
Created almost 2 years ago
· Last pushed over 1 year ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# igr: Irish Grid References in R
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://CRAN.R-project.org/package=igr)
[](https://github.com/digitalnature-ie/igr/actions/workflows/R-CMD-check.yaml)
[](https://github.com/digitalnature-ie/igr/actions/workflows/test-coverage.yaml)
[](https://app.codecov.io/gh/digitalnature-ie/igr?branch=main)
Convert between Irish grid references and Irish Grid coordinates, or an sf object in any coordinate reference system.
An Irish grid reference is a way of referring to a square of certain size on the Irish Grid geographic coordinate system ([EPSG:29903](https://epsg.io/29903)). Rather than an X and Y coordinate, an Irish grid reference consists of a letter, optionally followed by an easting, northing and possibly a final letter. The size of the square referred to - the precision of the Irish grid reference - is defined by the number of digits in the easting and northing and presence or absence of a final letter. Spaces are sometimes inserted between letters, easting and northing for legibility.
For example:
* "N" refers to a particular 100 km square ("N" is the square highlighted in orange in the igr logo)
* "N16" refers to a particular 10 km square within "N"
* "N16K" is the tetrad form of grid reference and refers to a particular 2 km square within "N16"
* "N 12345 67890" refers to a particular 1 m square
This package supports Irish grid references of 100 km, 10 km, 2 km, 1 km, 100 m, 10 m, and 1 m precision. Datasets containing a mix of precision are supported.
Irish grid references can be converted to and from Irish Grid coordinates (X and Y), or to and from [sf](https://r-spatial.github.io/sf/) (simple feature) objects in any coordinate reference system.
Irish grid references can be converted to point locations or polygons. Point locations can be either the south-west corner or the centroid of each Irish grid reference. Polygons each span the entire extent of an Irish grid reference - the size of each polygon is precision-aware.
## Installation
To install the production version of igr from CRAN:
``` r
install.packages("igr")
```
To install the development version of igr from GitHub:
``` r
# Install remotes package if needed
install.packages("remotes")
# Install development version of igr package from GitHub
remotes::install_github("digitalnature-ie/igr")
```
## Usage
To check validity of Irish grid references:
* `igr_is_valid()` indicates which elements in a character vector are valid Irish grid references
To convert from Irish grid references:
* `igr_to_ig()` converts from a vector of Irish grid references to a matrix of Irish Grid coordinates
* `st_igr_as_sf()` converts from a data.frame containing Irish grid references to an sf object containing points or polygons
To convert to Irish grid references:
* `ig_to_igr()` converts from a list or matrix of Irish Grid coordinates to Irish grid references
* `st_irishgridrefs()` converts from an sf object to Irish grid references
### Check Irish grid references
```{r example-igr-valid}
library(igr)
# Sample grid references
igrs <- c("A", "A16", "A123678", "BAD", "I12", "", "B125", "Z", "N12D")
igr_is_valid(igrs)
```
### Convert from Irish grid references
```{r example-igr-as-sf}
# Sample grid references
igrs <- c("A", "D12", "J53", "M5090", "N876274", "S1234550000", "R10H", "X")
# Converting south west corners of Irish grid references to Irish Grid coordinates
igr_to_ig(igrs)
# Converting centroids of Irish grid references to Irish Grid coordinates
igr_to_ig(igrs, centroids = TRUE)
# Sample grid references in a data.frame
igrs_df <- data.frame(igr = igrs)
# Converting to an sf object of POINT features
st_igr_as_sf(igrs_df, "igr")
# Converting to an sf object of POINT features in WGS 84 - Longitude and Latitude
st_igr_as_sf(igrs_df, "igr", crs = 4326)
```
```{r example-igr-points, message=FALSE, echo=FALSE, warning=FALSE, fig.alt="A map of Ireland with a dot at the south west corner of each sample grid reference."}
if (requireNamespace("maps", quietly = TRUE) &
requireNamespace("tmap", quietly = TRUE) &
requireNamespace("units", quietly = TRUE)) {
library(maps)
library(tmap)
library(units)
points_sf <- st_igr_as_sf(igrs_df, "igr")
ie_uk_sf <- maps::map("world",
regions = c("Ireland", "UK"),
plot = FALSE,
fill = TRUE
) |>
sf::st_as_sf(ie_uk) |>
sf::st_transform(29903)
tm_shape(points_sf, ext = 1.4) +
tm_dots(size = 1, fill = "cornflowerblue") +
tm_text("igr", ymod = 1) +
tm_shape(ie_uk_sf) +
tm_borders()
}
```
```{r example-igrt-as-sf-polygons}
# Converting to an sf object of POLYGON features
st_igr_as_sf(igrs_df, "igr", polygon = TRUE)
```
```{r example-igr-polygons, message=FALSE, echo=FALSE, warning=FALSE, fig.alt="A map of Ireland with polygons spanning each sample grid reference. The polygons range in size from 100 km square to 1 m square."}
if (requireNamespace("maps", quietly = TRUE) & requireNamespace("tmap", quietly = TRUE)) {
polygons_sf <- st_igr_as_sf(igrs_df, "igr", polygons = TRUE)
# identify small polygons requiring highlighting
polygons_sf$area <- sf::st_area(polygons_sf)
small_polygons_sf <- polygons_sf[polygons_sf$area <= units::set_units(5000000, m^2), ]
tm_shape(ie_uk_sf, bbox = points_sf, ext = 1.4) +
tm_borders() +
tm_shape(polygons_sf) +
tm_polygons(fill = "cornflowerblue", fill_alpha = 0.5) +
tm_text("igr", ymod = -1) +
tm_shape(small_polygons_sf) +
tm_bubbles(
fill_alpha = 0, col = "orangered", lwd = 2,
size = 0.8
)
}
```
### Convert to Irish grid references
```{r example-ig-to-igr}
# Sample Irish Grid coordinates
p <- matrix(c(0, 490000, 400000, 0, 453000, 4000), ncol = 2, byrow = TRUE)
colnames(p) <- c("x", "y")
p
# Convert to Irish grid references
ig_to_igr(p)
# Sample Irish Grid coordinates in an sf object
p_sf <- sf::st_as_sf(data.frame(p), crs = 29903, coords = c("x", "y"))
# Convert sf object to Irish grid references
st_irishgridrefs(p_sf, sep = " ")
```
```{r example-append-igr, eval = FALSE}
# Append Irish grid references to original sf object (using base R)
p_sf$igr <- st_irishgridrefs(p_sf)
# Append Irish grid references to original sf object (using tidy R)
p_sf <- p_sf |>
dplyr::mutate(igr = st_irishgridrefs(p_sf))
```
# Design and Implementation
This package is designed to work seamlessly in tidy R. Function names, parameter names, and function behaviour attempt to follow conventions in related R packages such as [sf](https://r-spatial.github.io/sf/).
igr is written using base R where possible to minimise package dependencies, and adopts the [tidyverse coding style](https://style.tidyverse.org/).
[R Packages](https://r-pkgs.org/), 2nd edition, by Hadley Wickham and Jennifer Bryan was of great assistance during package development.
# Feedback
Please log any unexpected behaviour or suggestions via GitHub [Issues](https://github.com/digitalnature-ie/igr/issues). If you find igr useful or interesting please consider starring the project on [GitHub](https://github.com/digitalnature-ie/igr).
Owner
- Name: Digital Nature
- Login: digitalnature-ie
- Kind: organization
- Email: info@digitalnature.ie
- Location: Ireland
- Website: www.digitalnature.ie
- Repositories: 1
- Profile: https://github.com/digitalnature-ie
Geospatial Data, GIS, IT Solutions
GitHub Events
Total
- Create event: 1
- Release event: 1
- Issues event: 4
- Watch event: 4
- Issue comment event: 1
- Push event: 11
Last Year
- Create event: 1
- Release event: 1
- Issues event: 4
- Watch event: 4
- Issue comment event: 1
- Push event: 11
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: 9 days
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 1.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: 9 days
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 1.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- jkennedyie (8)
- cmmckeon (1)
Pull Request Authors
- jkennedyie (4)
Top Labels
Issue Labels
enhancement (3)
Pull Request Labels
enhancement (2)
Packages
- Total packages: 1
-
Total downloads:
- cran 173 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
cran.r-project.org: igr
Irish Grid Reference Utilities
- Homepage: https://github.com/digitalnature-ie/igr
- Documentation: http://cran.r-project.org/web/packages/igr/igr.pdf
- License: GPL (≥ 3)
-
Latest release: 1.0.0
published over 1 year ago
Rankings
Dependent packages count: 28.5%
Dependent repos count: 35.1%
Average: 50.1%
Downloads: 86.7%
Maintainers (1)
Last synced:
10 months ago
Dependencies
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.5.0 composite
- actions/checkout v4 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v4 composite
- actions/upload-artifact v4 composite
- codecov/codecov-action v4 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- sf * imports
- knitr * suggests
- maps * suggests
- rmarkdown * suggests
- testthat >= 3.0.0 suggests
- tmap * suggests