GeocodeCN
is a simple wrapper around common APIs for geocoding Chinese location. Currently supports Amap and Baidu Map.
# make sure package 'devtools' is installed
devtools::install_github("tmasjc/GeocodeCN")
Go to the followng links and apply for web services API,
Amap - http://lbs.amap.com/
Baidu - http://lbsyun.baidu.com/
library(GeocodeCN)
# default using amap
geocode("北京市朝阳区朝阳公园", key = "Your_Api_Key_Here")
These APIs require application key to work. It will be more convenient to store your application keys in your environment as variables.
# amap_key = "amap_api_key_put_here"
# baidu_key = "baidu_api_key_put_here"
# ...
file.edit("~/.Renviron")
##--- Restart R session to take effect ---##
amap_ak = Sys.getenv("amap_key")
baidu_ak = Sys.getenv("baidu_key")
geocode("北京市海淀区双清路30号", key = amap_ak)
geocode("上海市长宁区武夷花园", api = "baidu", key = baidu_ak, output = "XML")
Non-Baidu standard geocode can be converted to Baidu standard geocode.
geoconv("116.329315", "40.004472", key = "Baidu_Map_Api_Key")
This package is in primitive stage of development. More features are coming soon.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.