This function returns the grid reference's easting in metres.
easting(x, ...) # S3 method for gridref easting(grid_reference, centre = FALSE)
grid_reference | A Great British or Irish grid reference character string with class gridref. |
---|---|
centre | Should the easting be for the lower left hand corner (default FALSE) or the centre point (TRUE). |
The easting of grid reference in metres.
It can check either British or Irish grid references up to 10 figure (1m precision), including tetrads (2000m precision).
A REST API endpoint is available once a Plumber router has been created and can be requested by adding _api to the end of the function.
The API returns "" instead of NULL so that it may be used with the dplyr::mutate function. Wrap the API call with dplyr::na_if to convert "" to NA.
suppressPackageStartupMessages({ library(store) suppressWarnings({ library(plumber) }) }) pr("../R/gridref_api.R") %>% pr_run(port = 8000)
Other grid reference functions:
gridsquare_geometry()
,
hectad()
,
hectare()
,
monad()
,
northing()
,
pentad()
,
precision()
,
projection()
,
tetrad()
suppressPackageStartupMessages({ library(store) suppressWarnings({ library(dplyr) library(janitor) }) }) grid_references <- nbn_demonstration_dataset %>% clean_names() %>% slice_tail(n = 15) %>% select(grid_reference) %>% mutate(grid_reference = as_gridref(grid_reference)) # add easting column for the centre point suppressPackageStartupMessages({ suppressWarnings({ library(dplyr) }) }) grid_references %>% rowwise() %>% mutate(easting_corner = easting(grid_reference), easting_centre = easting(grid_reference, centre = TRUE))#> # A tibble: 15 x 3 #> # Rowwise: #> grid_reference easting_corner easting_centre #> <gridref> <dbl> <dbl> #> 1 TL2384 523000 523500 #> 2 TL232839 523200 523250 #> 3 TL2385 523000 523500 #> 4 TL231840 523100 523150 #> 5 TL232839 523200 523250 #> 6 TL23248346 523240 523245 #> 7 TL23568493 523560 523565 #> 8 TL23448505 523440 523445 #> 9 TL23128324 523120 523125 #> 10 TL234850 523400 523450 #> 11 TL234846 523400 523450 #> 12 TL232839 523200 523250 #> 13 TL231841 523100 523150 #> 14 TL226846 522600 522650 #> 15 TL2384 523000 523500