easting_api: easting_api

easting_apiR Documentation

easting_api

Description

This function returns the grid reference's easting in metres.

Usage

easting_api(grid_reference, centre = FALSE)

Arguments

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).

Details

It can check either British or Irish grid references up to 10 figure (1m precision), including tetrads (2000m precision).

Value

The easting of grid reference in metres.

REST API

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({
  suppressWarnings({
    library(plumber)
  })
})
pr("../R/gridref_api.R") %>%
  pr_run(port = 8000)

See Also

Other grid reference functions: gridsquare_geometry(), hectad(), hectare(), monad(), northing(), pentad(), precision(), projection(), ten_metre(), tetrad()

Examples

 suppressPackageStartupMessages({
   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))

gcfrench/store documentation built on May 17, 2024, 5:52 p.m.