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

View source: R/geocode.R

geocodeR Documentation

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)

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.

Value

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

Examples


# 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)


openmeteo documentation built on Oct. 25, 2023, 5:07 p.m.