The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Geocoding and Reverse Geocoding Services are widely used to provide data about coordinate and location information, including longitude, latitude, formatted location name, administrative region with different levels. There are some packages can provide geocode service such as tidygeocoder, baidumap, and baidugeo. However, some of them do not always provide precise information in China, and some of them are unavailable with the upgrade backend API.
amapGeocode is built to provide high precise geocoding and reverse
geocoding service, and it provides an interface for the AutoNavi(高德)
Maps API geocoding services. API docs can be found here and here. Here are
two main functions to use, one is getCoord() which needs a
character location name as an input, while the other one is
getLocation() which needs two numeric longitude and
latitude values as inputs.
The getCoord() function extracts coordinate information
from input character location name and outputs the results as
tibble, XML or JSON (as list).
And the getLocation() function extracts location
information from input numeric longitude and latitude values and outputs
the results as tibble, XML or
JSON (as list). With the tibble format as
output, it’s highly readable and can be used as an alternative of
data.frame
amapGeocode is inspired by baidumap and baidugeo. If you want to choose the Baidu Map API, these packages are good choices.
However, AutoNavi has significant high precise, in my case, the Results from Baidu were unsatisfactory.
amap_api_error) and automatic propagation of rate-limit
headers.amap_sign(),
with_amap_signature(), and amap_config() keeps
sensitive secrets out of function calls.getCoord() now supports mode = "all" for
multi-match lookups as well as batch = TRUE to resolve up
to ten addresses per request while preserving input order.getLocation() gains batching plus rich POI, road,
intersection, and AOI list-columns via the details argument
when extensions = "all".extractAdmin() traverses every matching parent region,
returning tidy parent metadata and optional boundary polylines when
extensions = "all".You can install the released version of amapGeocode from CRAN with:
install.packages("amapGeocode")To install the development version, run following command:
remotes::install_github('womeimingzi11/amapGeocode')Before start geocoding and reverse geocoding, please apply a AutoNavi Map API Key. Set
amap_key globally by following command:
Then get results of geocoding, by getCoord function.
library(amapGeocode)
# An individual request
res <- getCoord("四川省博物馆")
knitr::kable(res)
# Batch requests
res <- getCoord(c("四川省博物馆", "成都市博物馆", "四川省成都市武侯区金楠天街"),
batch = TRUE)
knitr::kable(res)Retrieve every candidate for a single query:
getCoord("四川省博物馆", mode = "all")The responses we get from AutoNavi Map API is
JSON or XML. For readability, we
transform them to tibble,
by setting output argument as tibble by
default.
If you want to extract information from JSON or
XML. The results can further be parsed by
extractCoord.
# An individual request
res <- getCoord("四川省博物馆", output = "JSON")
resextractCoord is created to get a result as a tibble.
tb <- extractCoord(res)
knitr::kable(tb)get results of reverse geocoding, by getLocation
function.
res <- getLocation(103.996, 30.6475)
knitr::kable(res)Request extended POI, road, and AOI details (requires
extensions = "all"):
getLocation(103.9960, 30.6475,
extensions = "all",
details = c("pois", "roads", "roadinters", "aois"))extractLocation is created to get a result as a
tibble.
get results of reverse geocoding, by getAdmin
function.
There is a difference between getAdmin and other function, no matter
the output argument is tibble or not, the
result won’t be a jointed table by different parent administrative
region. For example, with the output = tibble, all the
lower level administrative region of Province A and Province B will be
bound as one tibble, respectively. But the table of province A and table
of province B won’t be bound further.
Because this function supports different administrative region levels, it is nonsense to bind their results.
res <- getAdmin(c("四川省", "成都市", "济宁市"))
knitr::kable(res)Include boundary polylines (requires
extensions = "all"):
getAdmin("四川省", subdistrict = 0,
extensions = "all", include_polyline = TRUE)extractAdmin is created to get results as tibble.
get results of reverse geocoding, by convertCoord
function, here is how to convert coordinate from gps to AutoNavi.
Please not, this is still a very experimental function because I have no experience at converting coordinates. The implementation of this input method is not as delicate as I expect. If you have any good idea, please let me know or just fork repo and pull a reques.
res <- convertCoord("103.9960,30.6475", coordsys = "gps")
knitr::kable(res)extractConvertCoord is created to get result as
tibble.
AutoNavi’s enterprise endpoints can be secured with a digital signature. Instead of threading the signature through every call, enable signing globally:
amap_config(secret = "YOUR-SECRET")
getCoord("四川省博物馆")For temporary scopes, wrap the workflow with
with_amap_signature():
with_amap_signature("YOUR-SECRET", {
getCoord("四川省博物馆", batch = TRUE)
})It’s very common for API upgrades to make the downstream application, like amapGeocode,which is unavailable. Feel free to let me know once it’s broken or just open an Issue.
The ongoing development and maintenance of this project are powered by Gemini 3.
Hex Sticker was created by hexSticker package with the world data from rnaturalearth.
Please note that the amapGeocode project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.