geocode: Geocode character vectors using online services

Description Usage Arguments Value Author(s) Examples

View source: R/Contributed.R

Description

Geocode character vectors (or data.frames) using Google or Bing's API

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
geocode(x, verbose = FALSE, service = "google",
  returntype = "coordinates", ...)

## Default S3 method:
geocode(x, verbose = FALSE, service = "google",
  returntype = "coordinates", ...)

## S3 method for class 'data.frame'
geocode(x, verbose = FALSE, service = "google",
  returntype = "coordinates", addresscol = "address", ...)

Arguments

x

A vector or data.frame

verbose

Whether to display each address as it is submitted to Google or not

service

API to use. Current options are "bing" or "google". To add your Bing API key, set options(BingMapsKey="yourkeygoeshere").

returntype

What to return. Options include "coordinates" and "zip".

addresscol

A (character) name of the column in a data.frame which contains the addresses

...

Other items to pass along

Value

geocode.default returns a numeric vector of length 2 containing the latitudes and longitudes. geocode.data.frame returns the original data.frame with two additional columns for the longitude and latitudes.

Author(s)

Error handling, object orientation, and Bing capabilities by Ari Friedman. Google REST algorithm by Tony Breyal (http://stackoverflow.com/a/3259537/636656).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
geocode("3817 Spruce St, Philadelphia, PA 19104")
geocode("Philadelphia, PA")
dat <- data.frame(
 value=runif(3),
 address=c("3817 Spruce St, Philadelphia, PA 19104","Philadelphia, PA","Neverneverland")
)
geocode(dat)

## End(Not run)

gsk3/taRifx.geo documentation built on May 17, 2019, 8:56 a.m.