bmap_get_coords: Get Coordinates for a Vector of Locations.

Description Usage Arguments Value Examples

View source: R/get_coords.R

Description

Takes a vector of locations (address, business names, etc), sends them to the Baidu Maps API, output a char vector of coordinates, as json text objects. This function also implements a data dictionary, saved as an rda object, to avoid sending the same query to Baidu twice.

Usage

1
2
bmap_get_coords(location, type = c("data.frame", "json"),
  force = FALSE, skip_short_str = FALSE, cache_chunk_size = NULL)

Arguments

location

char vector, vector of locations.

type

string, dictates the return data type. Valid inputs are data.frame, which will return a data.frame, or json, which will return a vector of json strings.

force

logical, force online query, even if previously downloaded and saved to the data dictionary.

skip_short_str

logical, if TRUE then any input strings with length of three or less will not be queried in the Baidu API, and a json str with custom status code will be returned, indicating the str is too short to query. The idea is that if a str is three char's or less, then it's probably not an actual address, company/business name, or location. Default value is FALSE.

cache_chunk_size

integer, indicates how often you want the API return data to be saved to the package cache. Default value is NULL.

Value

char vector of json text objects. Each object contains the return value(s) from the Baidu Maps query, as well as the return value status code.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
locs <- c(
  "中百超市有限公司长堤街二分店", 
  "浙江省杭州市余杭区径山镇小古城村", 
  "成都高梁红餐饮管理有限公司"
)

bmap_get_coords(locs)

## End(Not run)

ChrisMuir/baidugeo documentation built on Feb. 7, 2020, 5 p.m.