Git Product home page Git Product logo

whatthreewords's Introduction

whatthreewords

R-CMD-check CRAN status

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.

whatthreewords's People

Contributors

davidasmith avatar

Watchers

 avatar

whatthreewords's Issues

Add link to description

Please add a web reference for the API in the form https:..... to the
description of the DESCRIPTION file with no space after 'https:' and
angle brackets for auto-linking.

Software naming conventions

Please always write package names, software names and API (application
programming interface) names in single quotes in title and description.
e.g: --> 'what3words'
Please note that package names are case sensitive.

Example exposes API key secret

Example for get_api_key() exposes API key when run in packagedown website build. API key currently compromised has been deleted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.