Learn R Programming

openmeteo (version 0.2.4)

geocode: Geocode a location using the Open-Meteo geocoding API

Description

Call the Open-Meteo Geocoding API to retrieve co-ordinates and other information for a given place name. The closest n matching records can be requested.

Geocoding API documentation is available at: https://open-meteo.com/en/docs/geocoding-api.

Usage

geocode(location_name, n_results = 1, language = "en", silent = TRUE)

Value

Details for each matching location (latitude, longitude, elevation, population, timezone, and administrative areas)

Arguments

location_name

Required. The location name to search for via fuzzy matching.

n_results

The number of matching locations provided in response, sorted by relevance (default 1, up to 100).

language

Desired response language for place names (lower-cased two-letter string, i.e. "en" for London,"fr" for Londres).

silent

If FALSE, the top match will be printed to the console, to aid in confirming the match is correct when used within other functions.

Examples

Run this code
# \donttest{
# obtain co-ordinates of Sydney
gc <- geocode("Sydney")
sydney_coords <- c(gc$latitude, gc$longitude)
sydney_coords

# elevation of Kathmandu
geocode("kathmandu")$elevation

# 10 places named 'Paris'
geocode("paris", 10)
# }

Run the code above in your browser using DataLab