knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
options(tibble.print_min = 5, tibble.print_max = 5)

library(dplyr)
library(tidygeocoder)

This page contains documentation relevant for those wishing to contribute to the package and specific instructions for how to add support for a new geocoding service.

Introduction

The two core functions to focus on in the package are geo() and reverse_geo(). These functions have very similar layouts, but geo() is for forward geocoding while reverse_geo() is for reverse geocoding. The geocode() and reverse_geocode() functions only extract input data from a dataframe and pass it to the geo() and reverse_geo() functions respectively for geocoding.

Both the geo() and reverse_geo() functions take inputs (either addresses or coordinates) and call other functions as needed to deduplicate the inputs, pause to comply with API usage rate policies, and execute queries. Key parameters and settings for geocoding are stored for easy access and display in built-in datasets.

Consider this query:

library(dplyr)
library(tidygeocoder)

df <- tibble(
  id = c(1, 2, 1),
  locations = c('tokyo', 'madrid', 'tokyo')
  )

df %>%
  geocode(address = locations, method = 'osm', full_results = TRUE, verbose = TRUE)

Here is what is going on behind the scenes:

Refer to the notes below on adding a geocoding service for more specific documentation on the code structure.

Adding a New Geocoding Service

This section documents how to add support for a new geocoding service to the package. Required changes are organized by file. If anything isn't clear, feel free to file an issue.

Base all changes on the main branch.

Files to Update

Other Files

These files don't necessarily need to be updated. However, you might need to make changes to these files if the service you are implementing requires some non-standard workarounds.

Testing

Releasing a New Version

To release a new version of tidygeocoder:

Last, run devtools::release() to release the new version once everything looks good.



jessecambon/tidygeocoder documentation built on Jan. 26, 2023, 4:03 p.m.