revgeocode: Reverse geocode

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

View source: R/geoCoord.R

Description

reverse geocodes a lat/lng location 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
revgeocode(latlng, ics = c("WGS-84", "GCJ-02", "BD-09"), api = c("google",
  "baidu"), key = "", output = c("address", "addressc"),
  messaging = FALSE, time = 0)

Arguments

latlng

a location in latitude/longitude format

ics

the coordinate system of inputing location, including WGS-84, GCJ-02 and BD-09, which are the GCSs of Google Earth, Google Map in China and Baidu Map, respectively. For location out of China, ics is automatically set to 'WGS-84' and other values are ignored.

api

use google or baidu maps api

key

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

output

formatted address or formmatted address with address components

messaging

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

time

the time interval to revgeocode, in seconds. Default value is zero. When you revgeocode multiple locations, 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 address or detail address components

Author(s)

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

See Also

geocode, 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
## Not run: 
# reverse geocode Beijing railway station
revgeocode(c(39.90105, 116.42079), ics = 'WGS-84', api = 'google',
           output = 'address')
revgeocode(c(39.90245, 116.42703), ics = 'GCJ-02', api = 'google',
           output = 'address', messaging = TRUE)
revgeocode(c(39.90851, 116.43351), ics = 'BD-09', api = 'google',
           output = 'addressc')
revgeocode(c(39.90851, 116.43351), ics = 'BD-09', api = 'baidu',
           key = 'your baidu maps api key', output = 'address')
revgeocode(c(39.90245, 116.42703), ics = 'GCJ-02', api = 'baidu',
           key = 'your baidu maps api key', output = 'address', messaging = TRUE)
revgeocode(c(39.90105, 116.42079), ics = 'WGS-84', api = 'baidu',
           key = 'your baidu maps api key', output = 'addressc')
# reverse geocode multiple locations
latlng = data.frame(lat = c(39.99837, 39.98565), lng = c(116.3203, 116.2998))
revgeocode(latlng, ics = 'WGS-84', api = 'google', output = 'address')
revgeocode(latlng, ics = 'WGS-84', api = 'google', output = 'address', time = 2)

## End(Not run)

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