opencage

CRAN Version CRAN Checks Status CRAN Downloads per Month R-universe status Project Status: Active – The project has reached a stable, usable state and is being actively developed. R-CMD-check Status on GitHub Actions codecov.io Status rOpenSci Peer-Review License

Geocode with the OpenCage API, either from place name to longitude and latitude (forward geocoding) or from longitude and latitude to the name and address of the location (reverse geocoding).

Installation

You can install {opencage} from CRAN, R-universe or GitHub like this:

r install.packages("opencage")

r install.packages( "opencage", repos = c("https://ropensci.r-universe.dev", getOption("repos")) )

r pak::pak("ropensci/opencage")

or with {remotes}

r remotes::install_github("ropensci/opencage")

Quickstart

For the best experience, we recommend that you read through the "Introduction to opencage" vignette (vignette("opencage")), but if you are in a hurry:

  1. Register at opencagedata.com/users/sign_up.
  2. Generate an API key at the OpenCage dashboard.
  3. Save your API key as an environment variable like OPENCAGE_KEY=yourkey in .Renviron. See help(oc_config) for alternative ways to set your OpenCage API key.

Now you are ready to turn place names into latitude and longitude coordinates:

library(opencage)
oc_forward_df(placename = "Sarzeau")

Or turn a set of coordinates into the name and address of the location:

oc_reverse_df(latitude = 51.5034070, longitude = -0.1275920)

But remember, the vignettes are really great! We have:

About OpenCage

The OpenCage API supports forward and reverse geocoding. Sources of OpenCage are open geospatial data including OpenStreetMap, DataScienceToolkit, GeoPlanet, Natural Earth Data, libpostal, GeoNames, and Flickr's shapefiles plus a whole lot more besides. Refer to the current full list of credits.

Code of Conduct

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



ropensci/opencage documentation built on Feb. 7, 2023, 8:48 p.m.