
Use tidygeocoder to convert an address or data frame with an address column to an sf object
Source:R/sf_to_df.R
address_to_sf.RdWraps tidygeocoder::geo() and tidygeocoder::geocode() to convert a
character string or a data frame with an address column. Additional
parameters passed to tidygeocoder::geocode() which passes ... parameters to
tidygeocoder::geo().
Usage
address_to_sf(
x,
address = "address",
method = "osm",
coords = c("lon", "lat"),
remove_coords = FALSE,
crs = NULL,
full_results = FALSE,
...,
call = caller_env()
)Arguments
- x
Data frame with an address column. Multiple address columns are not currently supported.
- address
Address column name, Default: 'address'
- method
Geocoding service to use, Default: 'osm'. Passed to
tidygeocoder::geocode()which passes it on totidygeocoder::geo(). Seetidygeocoder::geo()for supported services (e.g. "osm", "census", "arcgis", "google").- coords
Coordinate columns for input data.frame or output sf object (if geometry is 'centroid' or 'point') Default: c("lon", "lat").
- remove_coords
For
df_to_sf(), ifTRUE, remove the coordinate columns after converting a data frame to simple feature object; defaults toFALSE.- crs
Cordinate reference system to return, Default: 4326 for
sf_to_df()andNULLfordf_to_sf().- full_results
If
TRUE, return all columns from the geocoding service in addition to the latitude and longitude columns, Default:FALSE.- ...
Arguments passed on to
tidygeocoder::geocode.tbldataframe containing addresses
streetstreet address column name
citycity column name
countycounty column name
statestate column name
postalcodepostal code column name (zip code if in the United States)
countrycountry column name
latlatitude column name. Can be quoted or unquoted (ie.
lator"lat").longlongitude column name. Can be quoted or unquoted (ie.
longor"long").return_inputif TRUE then the input dataset will be combined with the geocoder query results and returned. If FALSE only the geocoder results will be returned.
limitmaximum number of results to return per input address. For many geocoding services the maximum value of the limit parameter is 100. Pass
limit = NULLto use the defaultlimitvalue of the selected geocoding service. For batch geocoding, limit must be set to 1 (default) ifreturn_addresses = TRUE.To uselimit > 1orlimit = NULLset return_input to FALSE. Refer to api_parameter_reference for more details.return_addressesif TRUE return input addresses. Defaults to TRUE if
return_inputis FALSE and FALSE ifreturn_inputis TRUE. This argument is passed to thegeo()function.unique_onlyif TRUE then only unique results will be returned and return_input will be set to FALSE.
- call
The execution environment of a currently running function, e.g.
caller_env(). The function will be mentioned in error messages as the source of the error. See thecallargument ofabort()for more information.