Skip to contents

Geocodes addresses given as character values.

Usage

geo_lite(
  address,
  lat = "lat",
  long = "lon",
  limit = 1,
  full_results = FALSE,
  return_addresses = TRUE,
  verbose = FALSE,
  custom_query = list()
)

Arguments

address

single line address (i.e. "1600 Pennsylvania Ave NW, Washington") or a vector of addresses (c("Madrid", "Barcelona")).

lat

latitude column name (i.e. "lat").

long

longitude column name (i.e. "long").

limit

maximum number of results to return per input address. Note that each query returns a maximum of 50 results.

full_results

returns all available data from the geocoding service if TRUE. If FALSE (default) then only latitude and longitude columns are returned from the geocoding service.

return_addresses

return input addresses with results if TRUE. Note that most services return the input addresses with full_results = TRUE and setting return_addresses to FALSE does not prevent this.

verbose

if TRUE then detailed logs are output to the console. FALSE is default. Can be set permanently with options(tidygeocoder.verbose = TRUE)

custom_query

API-specific parameters to be used, passed as a named list (i.e. list(countrycodes = "US")). See Details.

Value

A tibble with the results.

Details

See https://nominatim.org/release-docs/latest/api/Search/ for additional parameters to be passed to custom_query.

Examples

# \donttest{
geo_lite("Madrid, Spain")
#> # A tibble: 1 × 4
#>   query           lat   lon address                                             
#>   <chr>         <dbl> <dbl> <chr>                                               
#> 1 Madrid, Spain  40.4 -3.70 Madrid, Área metropolitana de Madrid y Corredor del…

# Several addresses
geo_lite(c("Madrid", "Barcelona"))
#> # A tibble: 2 × 4
#>   query       lat   lon address                                                 
#>   <chr>     <dbl> <dbl> <chr>                                                   
#> 1 Madrid     40.4 -3.70 Madrid, Área metropolitana de Madrid y Corredor del Hen…
#> 2 Barcelona  41.4  2.18 Barcelona, Barcelonès, Barcelona, Catalunya, 08001, Esp…

# With options: restrict search to USA
geo_lite(c("Madrid", "Barcelona"),
  custom_query = list(countrycodes = "US"),
  full_results = TRUE
)
#> # A tibble: 2 × 21
#>   query     lat   lon address place_id licence osm_type osm_id boundingbox class
#>   <chr>   <dbl> <dbl> <chr>      <int> <chr>   <chr>     <int> <list>      <chr>
#> 1 Madrid   41.9 -93.8 Madrid…   2.82e8 Data ©… relation 1.29e5 <chr [4]>   boun…
#> 2 Barcel…  31.9 -91.4 Barcel…   3.19e5 Data ©… node     1.52e8 <chr [4]>   place
#> # … with 11 more variables: type <chr>, importance <dbl>, icon <chr>,
#> #   town <chr>, county <chr>, state <chr>, `ISO3166-2-lvl4` <chr>,
#> #   postcode <chr>, country <chr>, country_code <chr>, hamlet <chr>
# }