Takes a dataframe containing addresses as an input and returns the dataframe results from a specified geocoder service by using the geo function. See example usage in vignette("tidygeocoder").

This function passes all additional parameters (...) to the geo function, so you can refer to its documentation for more details on possible arguments.

Note that the arguments used for specifying address columns (address, street, city, county, state, postalcode, and country) accept either quoted or unquoted column names (ie. "address_col" and address_col are both acceptable).

geocode(
  .tbl,
  address = NULL,
  street = NULL,
  city = NULL,
  county = NULL,
  state = NULL,
  postalcode = NULL,
  country = NULL,
  lat = lat,
  long = long,
  return_addresses = FALSE,
  unique_only = FALSE,
  ...
)

Arguments

.tbl

dataframe containing addresses

address

single line street address column name. Do not combine with address component arguments (street, city, county, state, postalcode, country)

street

street address column name

city

city column name

county

county column name

state

state column name

postalcode

postalcode column name (zip code if in the United States)

country

country column name

lat

latitude column name. Can be quoted or unquoted (ie. lat or 'lat').

long

longitude column name. Can be quoted or unquoted (ie. long or 'long').

return_addresses

if TRUE then addresses with standard names will be returned This is defaulted to FALSE because the address fields are already in the input dataset

unique_only

if TRUE then only unique addresses and results will be returned. The input dataframe's format is not preserved. Addresses will also be returned if TRUE (overrides return_addresses argument).

...

arguments passed to the geo function

Value

input dataframe (.tbl) with geocoder results appended as columns

See also

Examples

# \donttest{ library(dplyr)
#> #> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’: #> #> filter, lag
#> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union
sample_addresses[1:2,] %>% geocode(addr)
#> # A tibble: 2 x 4 #> name addr lat long #> <chr> <chr> <dbl> <dbl> #> 1 White House 1600 Pennsylvania Ave Washington, DC 38.9 -77.0 #> 2 Transamerica Pyramid 600 Montgomery St, San Francisco, CA 94111 37.8 -122.
louisville[1:2,] %>% geocode(street = street, city = city, state = state, postalcode = zip)
#> # A tibble: 2 x 8 #> street city state zip latitude longitude lat long #> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 2722 ELLIOTT AVE Louisville Kentucky 40211 38.3 -85.8 38.3 -85.8 #> 2 850 WASHBURN AVE Louisville Kentucky 40222 38.3 -85.6 38.3 -85.6
sample_addresses[8:9,] %>% geocode(addr, method = 'osm', lat = 'lattes', long = 'longos')
#> # A tibble: 2 x 4 #> name addr lattes longos #> <chr> <chr> <dbl> <dbl> #> 1 Istanbul Istanbul, Turkey 41.0 29.0 #> 2 Tokyo Tokyo, Japan 35.7 140.
sample_addresses[4:5,] %>% geocode(addr, method = 'cascade', lat = latitude, long = longitude)
#> # A tibble: 2 x 5 #> name addr latitude longitude geo_method #> <chr> <chr> <dbl> <dbl> <chr> #> 1 Willis Tower 233 S Wacker Dr, Chicago, IL 606… 41.9 -87.6 census #> 2 Château Front… 1 Rue des Carrières, Québec, QC … 46.8 -71.2 osm
# }