geocode: Geocode

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/geoCoord.R

Description

geocodes an address using Google or Baidu Maps API. Note that in most cases by using this function you are agreeing to the Google Maps API Terms of Service at https://developers.google.com/maps/terms or the Baidu Maps API Terms of Use at http://developer.baidu.com/map/law.htm.

Usage

1
2
3
geocode(address, api = c("google", "baidu"), key = "", ocs = c("WGS-84",
  "GCJ-02", "BD-09"), output = c("latlng", "latlngc", "latlnga"),
  messaging = FALSE, time = 0)

Arguments

address

a character vector specifying a location of interest (e.g., "Tsinghua Univeristy").

api

use Google or Baidu Maps API. When using Baidu Maps API, the address must be in Chinese.

key

an api key must be provided when calling baidu maps api. While it's unnecessary for calling google maps api.

ocs

output coordinate systems including WGS-84, GCJ-02 and BD-09, which are the GCSs of Google Earth, Google Map in China and Baidu Map, respectively. For address out of China, ocs is automatically set to 'WGS-84' and other values are igored.

output

lat/lng coordinates or lat/lng coordinates with location type (Goolge Map) | confidence (Baidu Map) or lat/lng coordinates with formated address and address components (only available for #' Google Map API).

messaging

turn messaging on/off. The default value is FALSE.

time

the time interval to geocode, in seconds. Default value is zero. When you geocode multiple addresses, set a proper time interval to avoid exceeding usage limits. For details see https://developers.google.com/maps/documentation/business/articles/usage_limits

Details

note that the google maps api limits to 2500 queries a day.

Value

a data.frame with variables lat/lng or lat/lng/conf

Author(s)

Jun Cai (cai-j12@mails.tsinghua.edu.cn), PhD student from Center for Earth System Science, Tsinghua University

See Also

revgeocode, geohost.

Google Maps API at http://code.google.com/apis/maps/documentation/geocoding/ and Baidu Maps API at http://developer.baidu.com/map/webservice-geocoding.htm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 
geocode('Tsinghua University', api = 'google', ocs = 'GCJ-02')
geocode('Tsinghua University', api = 'google', ocs = 'WGS-84',
        messaging = TRUE)
geocode('Beijing railway station', api = 'google', ocs = 'WGS-84',
        output = 'latlngc')
geocode('Beijing railway station', api = 'google', ocs = 'WGS-84',
        output = 'latlnga')
geocode(c('Tsinghua University', 'Beijing railway station'), api = 'google',
        ocs = 'GCJ-02')
geocode(c('Tsinghua University', 'Beijing railway station'), api = 'google',
        ocs = 'WGS-84', output = 'latlngc', messaging = TRUE)
geocode(c('Tsinghua University', 'Beijing railway station'), api = 'google',
        ocs = 'WGS-84', output = 'latlnga', messaging = TRUE)
geocode(c('Tsinghua University', 'Beijing railway station'), api = 'google',
        ocs = 'WGS-84', output = 'latlngc', messaging = TRUE, time = 2)
geocode('Beijing railway station', api = 'baidu', key = 'your baidu maps api key',
ocs = 'BD-09')
geocode('Beijing railway station', api = 'baidu', key = 'your baidu maps api key',
ocs = 'GCJ-02', messaging = TRUE)
geocode('Beijing railway station', api = 'baidu', key = 'your baidu maps api key',
ocs = 'BD-09', output = 'latlngc')
geocode(c('Tsinghua University', 'Beijing railway station'), api = 'baidu',
key = 'your baidu maps api key', ocs = 'BD-09')
geocode(c('Tsinghua University', 'Beijing railway station'), api = 'baidu',
key = 'your baidu maps api key', ocs = 'WGS-84', output = 'latlngc')

## End(Not run)

madlogos/recharts2 documentation built on May 21, 2019, 11:03 a.m.