Skip to content

Repository files navigation

arcgeocoder arcgeocoder website

CRAN statusCRAN resultsDownloadsR-CMD-checkcodecovcoverallsr-universeCodeFactorProject Status: Active – The project has reached a stable, usable state and is being actively developed.DOIstatus

arcgeocoder provides a lightweight interface to the ArcGIS REST API. It geocodes single-line and structured addresses, reverse geocodes coordinates and finds places by category.

The full site with examples and vignettes is available at https://dieghernan.github.io/arcgeocoder/.

Why arcgeocoder?

arcgeocoder accesses the ArcGIS REST API without requiring an API key or an additional HTTP package such as curl. It uses base R download functions, which keeps its dependency footprint small.

The package provides focused interfaces to the findAddressCandidates and reverseGeocode endpoints. It supports single-line addresses, structured address components, category filters and reverse geocoding.

Recommended packages

The following packages provide related geocoding features:

Installation

Install arcgeocoder from CRAN with:

install.packages("arcgeocoder")

Read the documentation for the development version at https://dieghernan.github.io/arcgeocoder/dev/.

You can install the development version of arcgeocoder with:

# install.packages("pak")pak::pak("dieghernan/arcgeocoder")

Alternatively, you can install arcgeocoder using the r-universe:

# Install arcgeocoder in R.
install.packages(
"arcgeocoder",
repos= c(
"https://dieghernan.r-universe.dev",
"https://cloud.r-project.org"
)
)

Usage

Geocoding and reverse geocoding

The examples in this section are adapted from the tidygeocoder package.

The arc_geo() function converts single-line addresses into geographic coordinates. It requires no API key or additional setup.

library(arcgeocoder)
library(dplyr)
# Create a data frame with addresses.some_addresses<- tribble(
~name, ~addr,
"White House", "1600 Pennsylvania Ave NW, Washington, DC",
"Transamerica Pyramid", "600 Montgomery St, San Francisco, CA 94111",
"Willis Tower", "233 S Wacker Dr, Chicago, IL 60606"
)
# Geocode the addresses.lat_longs<- arc_geo(
some_addresses$addr,
lat="latitude",
long="longitude",
progressbar=FALSE
)

By default, arc_geo() returns a small set of fields. Set full_results = TRUE to return all available API fields.

querylatitudelongitudeaddressscorexyxminyminxmaxymaxwkidlatestWkid
1600 Pennsylvania Ave NW, Washington, DC38.89768-77.036551600 Pennsylvania Ave NW, Washington, District of Columbia, 20500100-77.0365538.89768-77.0375538.89668-77.0355538.8986843264326
600 Montgomery St, San Francisco, CA 9411137.79516-122.40273600 Montgomery St, San Francisco, California, 94111100-122.4027337.79516-122.4037337.79416-122.4017337.7961643264326
233 S Wacker Dr, Chicago, IL 6060641.87867-87.63587233 S Wacker Dr, Chicago, Illinois, 60606100-87.6358741.87867-87.6368741.87767-87.6348741.8796743264326

Table 1: Example: geocoding addresses.

The arc_reverse_geo() function converts longitude and latitude values into addresses. Supply longitude values to x and latitude values to y. The following example uses the coordinates returned by the previous query. The address argument sets the name of the address column in the output.

reverse<- arc_reverse_geo(
x=lat_longs$longitude,
y=lat_longs$latitude,
address="address_found",
progressbar=FALSE
)
xyaddress_found
-77.0365538.89768White House, 1600 Pennsylvania Ave NW, Washington, DC, 20500, USA
-122.4027337.79516Chess Ventures, 600 Montgomery St, San Francisco, CA, 94111, USA
-87.6358741.87867The Metropolitan, 233 South Wacker Drive, Chicago, IL, 60606, USA

Table 2: Example: reverse geocoding addresses.

The arc_geo_categories() function finds places by category near a location or within a bounding box. Available categories are documented in the arc_categories dataset and in the ArcGIS category filtering documentation.

The following example finds food-related places, such as restaurants, coffee shops and bakeries, near the Eiffel Tower in France.

library(ggplot2) # For plotting.# Step 1: Locate the Eiffel Tower using a structured query.eiffel_tower<- arc_geo_multi(
address="Tour Eiffel",
city="Paris",
countrycode="FR",
langcode="FR",
custom_query=list(outFields="LongLabel")
)
# Display results.eiffel_tower|>
select(lon, lat, LongLabel)
#> # A tibble: 1 × 3#> lon lat LongLabel #> <dbl> <dbl> <chr> #> 1 2.29 48.9 Tour Eiffel, 3 Rue de l'Université, 75007, 7e Arrondissement, Par…# Use `lon` and `lat` as a reference location for `category = "Food"`.food_eiffel<- arc_geo_categories(
"Food",
x=eiffel_tower$lon,
y=eiffel_tower$lat,
limit=50,
full_results=TRUE
)
# Plot by food type.
ggplot(eiffel_tower, aes(x, y)) +
geom_point(shape=15, color="blue", size=4) +
geom_point(data=food_eiffel, aes(x, y, color=Type)) +
labs(
title="Food near the Eiffel Tower",
subtitle="Using arcgeocoder",
color="Type of place",
x="",
y="",
caption="Data from the ArcGIS REST API"
)

Example: Food places near the Eiffel Tower

Convert results to spatial data

Use the longitude and latitude columns returned by arcgeocoder to create an sf object:

library(sf)
eiffel_tower_sf<-eiffel_tower|>
select(lon, lat, LongLabel) |>
st_as_sf(
coords= c("lon", "lat"),
# Set the CRS of the resulting coordinates.crs=eiffel_tower$wkid
)
food_eiffel_sf<- st_as_sf(food_eiffel,
coords= c("lon", "lat"),
crs=eiffel_tower$wkid
)
ggplot(eiffel_tower_sf) +
geom_sf(shape=15, color="blue", size=4) +
geom_sf(data=food_eiffel_sf, aes(color=Type)) +
coord_sf(crs=3035)

Example: Food places near the Eiffel Tower using the sf package.

Citation

Hernangómez D (2026). arcgeocoder: Address and Coordinate Search with the ArcGIS REST API. doi:10.32614/CRAN.package.arcgeocoder. https://dieghernan.github.io/arcgeocoder/.

A BibTeX entry for LaTeX users is shown below.

@Manual{R-arcgeocoder,
title = {{arcgeocoder}: Address and Coordinate Search with the {ArcGIS} {REST} {API}},
doi = {10.32614/CRAN.package.arcgeocoder},
author = {Diego Hernangómez},
year = {2026},
version = {0.4.1},
url = {https://dieghernan.github.io/arcgeocoder/},
abstract = {Provides a lightweight interface to the ArcGIS REST API for converting addresses and structured address components into geographic coordinates, finding places by category and converting coordinates into addresses. It uses the ArcGIS service documented at <https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm>. No API key is required.},
}

References

Cambon, Jesse, Diego Hernangómez, Christopher Belanger, and Daniel Possenriede. 2021. “tidygeocoder: An R Package for Geocoding.” Journal of Open Source Software 6 (65): 3544. https://doi.org/10.21105/joss.03544.

Hernangómez, Diego. 2024. nominatimlite: Interface with Nominatim API Service. Version 0.2.1. https://doi.org/10.5281/zenodo.5113195.

About

Geocode and reverse geocode addresses in R using the ArcGIS REST API, no API key required.

Topics

Resources

Code of conduct

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages