项目作者: joelgombin

项目描述 :
R client for the BAN API
高级语言: R
项目地址: git://github.com/joelgombin/banR.git
创建时间: 2016-05-25T21:56:09Z
项目社区:https://github.com/joelgombin/banR

开源协议:GNU General Public License v3.0

下载



output: github_document

An R client for the BAN API

R build status

The banR package is a light R client for the BAN API. The Base Adresse Nationale (BAN) is an open database of French adresses, produced by OpenStreetMap, La Poste, the IGN and Etalab.

banR can be installed from Github (current version):

  1. # install.packages("devtools")
  2. devtools::install_github("joelgombin/banR", build_vignettes = TRUE)

The CRAN version is out of date :

  1. install.packages("banR")

banR allows to geocode lots of adresses in batch (the only hard limit is that, at the moment, the API only allows CSV files up to 50 MB). Please be gentle with the server though!

banR is designed to be used in a data exploration workflow, with a syntax ‘à la tidyverse‘:

  1. library(dplyr)
  2. library(banR)
  3. data("paris2012")
  4. paris2012 %>%
  5. slice(1:100) %>%
  6. mutate(adresse = paste(numero, voie, nom),
  7. code_insee = paste0("751", arrondissement)) %>%
  8. geocode_tbl(adresse = adresse, code_insee = code_insee) %>%
  9. glimpse()
  10. #> Writing tempfile to.../tmp/Rtmp9YlNra/file147282c595535.csv
  11. #> If file is larger than 50 MB, it must be splitted
  12. #> Size is : 3 Kb
  13. #> SuccessOKSuccess: (200) OK
  14. #> Rows: 100
  15. #> Columns: 25
  16. #> $ arrondissement <chr> "06", "06", "06", "06", "06", "06", "06", "06", "06…
  17. #> $ bureau <chr> "09", "09", "09", "09", "09", "09", "09", "09", "09…
  18. #> $ numero <int> 4, 5, 6, 7, 8, 11, 12, 13, 14, 16, 3, 4, 5, 6, 7, 8…
  19. #> $ voie <chr> "RUE DE L", "RUE DE L", "RUE DE L", "RUE DE L", "RU…
  20. #> $ nom <chr> "ABBAYE", "ABBAYE", "ABBAYE", "ABBAYE", "ABBAYE", "…
  21. #> $ nb <int> 1, 1, 20, 2, 17, 2, 9, 15, 17, 8, 13, 6, 6, 3, 9, 1…
  22. #> $ ID <chr> "0609", "0609", "0609", "0609", "0609", "0609", "06…
  23. #> $ adresse <chr> "4 RUE DE L ABBAYE", "5 RUE DE L ABBAYE", "6 RUE DE…
  24. #> $ code_insee <chr> "75106", "75106", "75106", "75106", "75106", "75106…
  25. #> $ latitude <dbl> 48.85405, 48.85407, 48.85414, 48.85410, 48.85425, 4…
  26. #> $ longitude <dbl> 2.335715, 2.335172, 2.335352, 2.335041, 2.334903, 2…
  27. #> $ result_label <chr> "4 Rue de l’Abbaye 75006 Paris", "5 Rue de l’Abbaye…
  28. #> $ result_score <dbl> 0.97, 0.97, 0.97, 0.97, 0.97, 0.97, 0.97, 0.97, 0.9…
  29. #> $ result_type <chr> "housenumber", "housenumber", "housenumber", "house…
  30. #> $ result_id <chr> "75106_0002_00004", "75106_0002_00005", "75106_0002…
  31. #> $ result_housenumber <chr> "4", "5", "6", "7", "8", "11", "12", "13", "14", "1…
  32. #> $ result_name <chr> "Rue de l’Abbaye", "Rue de l’Abbaye", "Rue de l’Abb…
  33. #> $ result_street <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
  34. #> $ result_postcode <chr> "75006", "75006", "75006", "75006", "75006", "75006…
  35. #> $ result_city <chr> "Paris", "Paris", "Paris", "Paris", "Paris", "Paris…
  36. #> $ result_context <chr> "75, Paris, Île-de-France", "75, Paris, Île-de-Fran…
  37. #> $ result_citycode <chr> "75106", "75106", "75106", "75106", "75106", "75106…
  38. #> $ result_oldcitycode <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
  39. #> $ result_oldcity <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
  40. #> $ result_district <chr> "Paris 6e Arrondissement", "Paris 6e Arrondissement…

To know more about this package, please read the vignette (vignette("geocode"))

Please report issues and suggestions to the issues tracker.

See also

  • BAN-geocoder, python wrapper for adresse.data.gouv.fr
  • tidygeocoder, r package similar to banR using other geocoding services such as US Census geocoder, Nominatim (OSM), Geocodio, and Location IQ.