MyNixOS website logo
Description

Work with the 'what3words' API for Easy Location Referencing.

Use the 'what3words' API <https://developer.what3words.com/public-api> to return three words which uniquely identify every 3m x 3m square on Earth. It is also possible to return coordinates from any valid three words location. Supports multiple languages.

whatthreewords

R-CMD-check

The whatthreewords package supports working with the what3words API from R. what3words has partitioned the surface of the earth into 3m x 3m squares, each of which can be identified by three words. These are conventionally styled with three slashes at the beginning. For example, the peak of the Great Pyramid of Giza is located by the three words ///ballots.height.silks.

You can use the package to determine the three word address for any coordinates, or return the coordinates for any valid three word combination.

Installation

You can install the development version of whatthreewords from GitHub with:

# install.packages("devtools")
devtools::install_github("DavidASmith/whatthreewords")

Authentication

The what3words API requires a key for authentication. You can register for a key at https://developer.what3words.com/public-api.

You must then set the WTW_API_KEY environment variable to hold your key. For example…

Sys.setenv(WTW_API_KEY = "MYKEY")

Examples

Here are a few examples of what you can do with the package. For more details, see the vignette ‘Using whatthreewords’.

Get a what3words address from coordinates

Use words_from_coords to get a what3words location for a given latitude and longitude.

library(whatthreewords)

words_from_coords(lat = 51.5095, 
                  lon = -0.1266)
#> [1] "lamp.inner.dent"

This is vectorised over lat and lon.

words_from_coords(lat = c(53.3703, 53.41145, 53.3096), 
                  lon = c(-1.47119, -1.500204, -1.478715))
#> [1] "elite.icon.levels" "weep.stands.shack" "soon.belt.owls"

Get coordinates from a what3words location

coords_from_words returns the coordinates for a what3words location.

coords_from_words("hours.flesh.petal")
#> Warning: ERROR: QuotaExceeded: Quota Exceeded. Please upgrade your usage plan,
#> or contact [email protected]
#>      lat lon
#> [1,]  NA  NA

Alternative packages

There is an alternative R client for what3words available on CRAN (Github repo). However, this has not been updated (at time of writing) for several years and I couldn’t get it to work. I needed something fairly quickly so wrote this from scratch.

Metadata

Version

0.1.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD 13
    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-freebsd13
  • 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-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows