{"id":31910257,"url":"https://github.com/womeimingzi11/amapgeocode","last_synced_at":"2025-10-13T16:20:32.943Z","repository":{"id":53480321,"uuid":"297431889","full_name":"womeimingzi11/amapGeocode","owner":"womeimingzi11","description":"An Interface to the AutoNavi Maps API Geocoding Services","archived":false,"fork":false,"pushed_at":"2025-02-28T02:00:10.000Z","size":342,"stargazers_count":14,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-12T10:53:01.651Z","etag":null,"topics":["autonavi","geocode","geocode-china","geocode-r","r"],"latest_commit_sha":null,"homepage":"https://womeimingzi11.github.io/amapGeocode/index.html","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/womeimingzi11.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-09-21T18:50:08.000Z","updated_at":"2025-05-10T07:59:47.000Z","dependencies_parsed_at":"2022-08-23T15:50:28.083Z","dependency_job_id":"d447949a-7a39-425f-9bfe-e5b4a1cf402a","html_url":"https://github.com/womeimingzi11/amapGeocode","commit_stats":{"total_commits":73,"total_committers":3,"mean_commits":"24.333333333333332","dds":0.0273972602739726,"last_synced_commit":"919348f18b63ac79911430bb081fdd4a78dc7580"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/womeimingzi11/amapGeocode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/womeimingzi11%2FamapGeocode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/womeimingzi11%2FamapGeocode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/womeimingzi11%2FamapGeocode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/womeimingzi11%2FamapGeocode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/womeimingzi11","download_url":"https://codeload.github.com/womeimingzi11/amapGeocode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/womeimingzi11%2FamapGeocode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016059,"owners_count":26085799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autonavi","geocode","geocode-china","geocode-r","r"],"created_at":"2025-10-13T16:20:30.709Z","updated_at":"2025-10-13T16:20:32.935Z","avatar_url":"https://github.com/womeimingzi11.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  tidy = TRUE\n)\n```\n\n\u003c!-- Place this tag in your head or just before your close body tag. --\u003e\n\u003c!--\u003cscript async defer src=\"https://buttons.github.io/buttons.js\"\u003e\u003c/script\u003e--\u003e\n\n# [amapGeocode](https://github.com/womeimingzi11/amapGeocode)\n\n\u003c!-- badges: start --\u003e\n[![Total downloads badge](https://cranlogs.r-pkg.org/badges/grand-total/amapGeocode?color=blue)](https://CRAN.R-project.org/package=amapGeocode)\n[![CRAN status](https://www.r-pkg.org/badges/version/amapGeocode)](https://CRAN.R-project.org/package=amapGeocode)\n[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#maturing)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![DOI](https://zenodo.org/badge/297431889.svg)](https://zenodo.org/badge/latestdoi/297431889)\n[![Codecov test coverage](https://codecov.io/gh/womeimingzi11/amapGeocode/branch/master/graph/badge.svg)](https://codecov.io/gh/womeimingzi11/amapGeocode?branch=master)\n[![R-CMD-check](https://github.com/womeimingzi11/amapGeocode/workflows/R-CMD-check/badge.svg)](https://github.com/womeimingzi11/amapGeocode/actions)\n\u003c!-- badges: end --\u003e\n\n中文版介绍: [博客](https://blog.washman.top/post/amapgeocode-%E4%BD%BF%E7%94%A8r%E8%BF%9B%E8%A1%8C%E9%AB%98%E5%BE%B7%E5%9C%B0%E5%9B%BE%E5%9C%B0%E7%90%86%E7%BC%96%E7%A0%81-%E9%80%86%E7%BC%96%E7%A0%81.zh-hans/) or [知乎](https://zhuanlan.zhihu.com/p/264281505)\n\n## Introduction  \u003cimg src=\"man/figures/hexSticker-logo.png\" align=\"right\" width=\"100\"/\u003e\n\nGeocoding 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](https://CRAN.R-project.org/package=tidygeocoder), [baidumap](https://github.com/badbye/baidumap) and [baidugeo](https://github.com/ChrisMuir/baidugeo). However, some of them do not always provide precise information in China, and some of them are unavailable with the upgrade backend API.\n\namapGeocode 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](https://lbs.amap.com/) and [here](https://lbs.amap.com/api/webservice/summary/). 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.\n\nThe `getCoord()` function extracts coordinate information from input character location name and outputs the results as `data.table`, `XML` or `JSON (as list)`. And the `getLocation()` function extracts location information from input numeric longitude and latitude values and outputs the results as `data.table`, `XML` or `JSON (as list)`. With the `data.table` format as output, it's highly readable and can be used as an alternative of `data.frame`\n\namapGeocode is inspired by [baidumap](https://github.com/badbye/baidumap) and [baidugeo](https://github.com/ChrisMuir/baidugeo). If you want to choose the Baidu Map API, these packages are good choices.\n\nHowever, AutoNavi has significant high precise, in my case, the Results from Baidu were unsatisfactory.\n\n## BIG NEWS: Parallel is Here! But you need a `plan`\n\nSince `v0.5.1`, parallel framework is implemented by [`furrr` package](https://CRAN.R-project.org/package=furrr), of which backend is [`future package`](https://arxiv.org/abs/2008.00553). Refering to [*A Future for R: Best Practices for Package Developers*](https://CRAN.R-project.org/package=future/vignettes/future-7-for-package-developers.html) and avoiding potential modification to the future strategy, we have removed the automatically parallel operation from every function in `amapGeocode`.\n\nTo turn on parallel operation support, just call `future::plan(multisession) # or any other future strategy`.\n\nSince `v0.5`, parallel operation finally comes to `amapGeocode` with the `parallel` package as the backend. There is a really huge performance improvement for batch queries. And you are welcomed to make a benchmark by following command.\n\n```r\nlibrary(amapGeocode)\nlibrary(future)\nlibrary(readr)\nsample_site \u003c-\n  read_csv(\"https://gist.githubusercontent.com/womeimingzi11/0fa3f4744f3ebc0f4484a52649f556e5/raw/47a69157f3e26c4d3bc993f3715b9ba88cda9d93/sample_site.csv\")\n\nstr(sample_site)\n\n# Here is the old implement\nstart_time \u003c- proc.time()\nold \u003c- lapply(sample_site$address, amapGeocode:::getCoord.individual)\nproc.time() - start_time\n\n# Here is the new implement\nplan(multisession)\nstart_time \u003c- proc.time()\nnew \u003c- getCoord(sample_site$address)\nproc.time() - start_time\n\n```\n\n*While parallel support is a totally threads depending operation, so you will get completely different speed on different devices.*\n\n## Installation\n\nYou can install the released version of amapGeocode from [CRAN](https://CRAN.R-project.org/package=amapGeocode) with:\n``` r\ninstall.packages(\"amapGeocode\")\n```\nTo install the development version, run following command:\n``` r\nremotes::install_github('womeimingzi11/amapGeocode')\n```\n\n## Usage\n### Geocoding\nBefore start geocoding and reverse geocoding, please apply a [AutoNavi Map API Key](https://lbs.amap.com/dev/). Set `amap_key` globally by following command:\n\n```{r set amap_key, eval=FALSE, include=FALSE}\noptions(amap_key = \"REPLACE THIS BY YOUR KEY\")\n```\n\nThen get results of geocoding, by `getCoord` function. \n\n```{r getCoord_to_table_as_TRUE}\nlibrary(amapGeocode)\n# An individual request\nres \u003c-\n  getCoord(\"四川省博物馆\")\nknitr::kable(res)\n# Batch requests\nres \u003c-\n  getCoord(c(\n    \"四川省博物馆\",\n    \"成都市博物馆\",\n    \"四川省成都市武侯区金楠天街\"\n  ))\nknitr::kable(res)\n```\n\nThe responses we get from **AutoNavi Map API** is **JSON** or **XML**. For readability, we transform them to [`data.table`](https://CRAN.R-project.org/package=data.table), by setting `output` argument as `data.table` by default.\n\nIf you want to extract information from **JSON** or **XML**. The results can further be parsed by `extractCoord`.\n\n```{r getCoord_to_table_as_FALSE}\n# An individual request\nres \u003c-\n  getCoord(\"四川省博物馆\", output = \"JSON\")\nres\n```\n\n`extractCoord` is created to get a result as a data.table.\n\n```{r extractCoord}\ntb \u003c-\n  extractCoord(res)\nknitr::kable(tb)\n```\n### Reverse Geocoding\n\nget results of reverse geocoding, by `getLocation` function. \n\n```{r getLocation_to_table_as_TRUE}\nres \u003c-\n  getLocation(103.9960,30.6475)\nknitr::kable(res)\n```\n\n`extractLocation` is created to get a result as a data.table.\n\n### Get Subordinate Administrative Region\n\nget results of reverse geocoding, by `getAdmin` function.\n\nThere is a difference between getAdmin and other function, no matter the `output` argument is `data.table` or not, the result won't be a jointed table by different parent administrative region. For example, with the `output = data.table`, all the lower level administrative region of Province A and Province B will be bound as one data.table, respectively. But the table of province A and table of province B won't be bound further.\n\nBecause this function supports different administrative region levels, it is nonsense to bind their results.\n\n```{r getAdmin_to_table_as_TRUE}\nres \u003c-\n  getAdmin(c(\"四川省\", \"成都市\", \"济宁市\"))\nknitr::kable(res)\n```\n\n`extractAdmin` is created to get results as tibble.\n\n### Convert coordinate point from other coordinate system to AutoNavi\n\nget results of reverse geocoding, by `convertCoord` function, here is how to convert coordinate from gps to AutoNavi.\n\n**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.**\n\n```{r convertCoord_to_table_as_TRUE}\nres \u003c-\n  convertCoord(\"103.9960,30.6475\", coordsys = \"gps\")\nknitr::kable(res)\n```\n\n`extractConvertCoord` is created to get result as data.table.\n\n## Bug report\nIt's very common for API upgrades to make the downstream application, like amapGeocode,which is unavailable. Feel free to [let me know](mailto://chenhan28@gmail.com) once it's broken or just open an \u003ca class=\"github-button\" href=\"https://github.com/womeimingzi11/amapGeocode/issues\" data-color-scheme=\"no-preference: light; light: light; dark: dark;\" data-size=\"large\" aria-label=\"Issue womeimingzi11/amapGeocode on GitHub\"\u003eIssue\u003c/a\u003e.\n\n## Acknowledgements\nHex Sticker was created by [hexSticker package](https://github.com/GuangchuangYu/hexSticker) with the world data from  [rnaturalearth](https://CRAN.R-project.org/package=rnaturalearth).\n\n## Code of Conduct\nPlease note that the amapGeocode project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwomeimingzi11%2Famapgeocode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwomeimingzi11%2Famapgeocode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwomeimingzi11%2Famapgeocode/lists"}