Learn R Programming

tidygeocoder (version 1.0.1)

geocode: Geocode addresses in a dataframe

Description

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

Usage

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

geo api_parameter_reference

Examples

Run this code
# NOT RUN {
library(dplyr)
sample_addresses[1:2,] %>% geocode(addr)

louisville[1:2,] %>% geocode(street = street, city = city, state = state,
  postalcode = zip)

sample_addresses[8:9,] %>% geocode(addr, method = 'osm',
  lat = 'lattes', long = 'longos')

sample_addresses[4:5,] %>% geocode(addr, method = 'cascade',
  lat = latitude, long = longitude)
# }

Run the code above in your browser using DataLab