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).
Install the package with:
Or install the development version using remotes with:
For the best experience, we recommend that you read through the “Introduction to opencage” vignette (
vignette("opencage")), but if you are in a hurry:
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:
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:
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.