geocodr: 'geocodr' This function batch geocodes csv files with the...

Description Usage Arguments Details Examples

View source: R/geocodr.R

Description

geocodr This function batch geocodes csv files with the help of the ggmap package, which uses the Google Maps API

Usage

1
2
geocodr(in_csv, api_key, address_col, out_file = "./output.csv",
  bg_map = "Canada", components = FALSE)

Arguments

in_csv

A character object. The name of the input CSV file with a column of addresses. If the full path is not given, the function assumes the file is in cwd

api_key

A character object. The API key provided by Google Maps API. Geocoding will not work without it.

address_col

A character object containing the name of the address column in the input file.

out_file

A character object. The desired name of the output CSV file. If the full path is not given, the function puts the file in cwd.

bg_map

A character object. The background map that will be pulled from Google Maps to plot the geocoded points. Defaults to 'Canada'.

components

Logical. If TRUE, the postal code will be included as a separate variable in the output file. Defaults to FALSE.

Details

The function takes as input a csv file, one column of which contains addresses. The addresses are geocoded, with lat and long appended as separate columns in the dataframe. Postal code can also be added separately if the user specifies components = TRUE. The resulting dataframe is written to an output csv file beside the input file.

Examples

1
2
3
4
5
## Not run: 
geocodr(in_csv = 'yk_test.csv', api_key = KEY, address_col = 'Business Address', components = FALSE)
geocodr(in_csv = 'organizations.csv', api_key = KEY, address_col = 'address', components = TRUE)

## End(Not run)

12mre1/geocodr documentation built on Oct. 30, 2019, 4:02 a.m.