MyNixOS website logo
Description

API Wrapper Around 'Postcodes.io'.

Free UK geocoding using data from Office for National Statistics. It is using several functions to get information about post codes, outward codes, reverse geocoding, nearest post codes/outward codes, validation, or randomly generate a post code. API wrapper around <https://postcodes.io>.

PostcodesioR

PostcodesioR

Travis-CI BuildStatus Package-License Project Status: Active – The project has reached a stable, usablestate and is being activelydeveloped. CRAN_Status_Badge DOI Downloads

An API wrapper around postcodes.io - free UK postcode lookup and geocoder. This package helps to find and transform information about UK administrative geography like postcodes, LSOA, MSOA, constituencies, counties, wards, districts, CCG or NUTS.

The package is based exclusively on open data provided by postcodes.io. PostcodesioR can be used by data scientists or social scientists working with geocoded UK data. A common task when working with such data is aggregating geocoded data on different administrative levels, e.g. turning postcode-level data into counties or regions. This package can help in achieving this and in many other cases when changing the aggregation of geographic data is required.

Installation

This package can be installed from GitHub (developmental version) or CRAN (stable).

In order to install PostcodesioR use one of the following commands:

# stable version
install.packages("PostcodesioR")

or

# developmental version
if(!require("devtools")) {
  install.packages("devtools")
}
devtools::install_github("ropensci/PostcodesioR")

Loading

Load the package by typing

library(PostcodesioR)

Examples

Where possible, I tried to return a data frame. Unfortunately, a lot of API calls return more complex data and in those cases it is safer to use lists. The API limits the number of returned calls. Check functions’ documentation for more details.

For additional information about the returned data and the function calls see the original documentation.

The main function of this package provides information related to a given postcode

lookup_result <- postcode_lookup("EC1Y8LX")

#overview
str(lookup_result)
## 'data.frame':    1 obs. of  35 variables:
##  $ postcode                       : chr "EC1Y 8LX"
##  $ quality                        : int 1
##  $ eastings                       : int 532544
##  $ northings                      : int 182128
##  $ country                        : chr "England"
##  $ nhs_ha                         : chr "London"
##  $ longitude                      : num -0.0909
##  $ latitude                       : num 51.5
##  $ european_electoral_region      : chr "London"
##  $ primary_care_trust             : chr "Islington"
##  $ region                         : chr "London"
##  $ lsoa                           : chr "Islington 023D"
##  $ msoa                           : chr "Islington 023"
##  $ incode                         : chr "8LX"
##  $ outcode                        : chr "EC1Y"
##  $ parliamentary_constituency     : chr "Islington South and Finsbury"
##  $ admin_district                 : chr "Islington"
##  $ parish                         : chr "Islington, unparished area"
##  $ admin_county                   : logi NA
##  $ admin_ward                     : chr "Bunhill"
##  $ ced                            : logi NA
##  $ ccg                            : chr "NHS North Central London"
##  $ nuts                           : chr "Haringey and Islington"
##  $ admin_district_code            : chr "E09000019"
##  $ admin_county_code              : chr "E99999999"
##  $ admin_ward_code                : chr "E05000367"
##  $ parish_code                    : chr "E43000209"
##  $ parliamentary_constituency_code: chr "E14000764"
##  $ ccg_code                       : chr "E38000240"
##  $ ccg_id_code                    : chr "93C"
##  $ ced_code                       : chr "E99999999"
##  $ nuts_code                      : chr "TLI43"
##  $ lsoa_code                      : chr "E01002704"
##  $ msoa_code                      : chr "E02000576"
##  $ lau2_code                      : chr "E09000019"

Check the vignette to see all functions in action.

Notes

Currently, there is a limit to the number of API calls that can be made. However, postcodes.io provides full list of geolocation data that can be used locally without limitations. The original data is sourced from Office for National Statistics Data Portal. That file is rather large so I didn’t include it in the package.

Go to the package’s website or to my blog for more examples.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

ropensci_footer

Metadata

Version

0.3.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows