geocode_osm_batch: Batch geocode addresses with OpenStreetMap

View source: R/geocode_osm_batch.R

geocode_osm_batchR Documentation

Batch geocode addresses with OpenStreetMap

Description

Function to find geographic coordinates of multiple addresses and place names, using OpenStreetMap's Nominatum API.

Usage

geocode_osm_batch(
  query,
  delay = 1,
  return_all = FALSE,
  match_num = 1,
  details = FALSE,
  user_agent = NULL,
  verbose = FALSE
)

Arguments

query

Addresses or place names to be geocoded. Character string.

delay

Delay between requests. Default is 1 second. Numeric.

return_all

Should all matches be returned? Overrides match_num if TRUE. Default is FALSE. Logical.

match_num

If query matches multiple locations, which match to return? Default is 1 (highest-ranking match, by relevance). Numeric.

details

Should detailed results be returned? Default is FALSE. Logical.

user_agent

Valid User-Agent identifying the application for OSM-Nominatum. If none supplied, function will attempt to auto-detect. Character string.

verbose

Print status messages and progress? Default is FALSE. Logical.

Details

Wrapper function for geocode_osm. Because Nominatim Usage Policy stipulates an absolute maximum of 1 request per second, this function facilitates batch geocoding by adding a small delay between queries (https://operations.osmfoundation.org/policies/nominatim/).

Value

A data.frame object. If details=FALSE, contains fields

  • "query". User-supplied address query(ies). Character string.

  • "osm_id". OpenStreetMap ID. Character string.

  • "address". OpenStreetMap address. Character string.

  • "longitude". Horizontal coordinate. Numeric.

  • "latitude". Vertical coordinate. Numeric.

If details=TRUE, contains additional fields

  • "osm_type". OpenStreetMap ID. Character string.

  • "importance". Relevance of Nominatum match to query, from 0 (worst) to 1 (best). Numeric.

  • "bbox_ymin". Minimum vertical coordinate of bounding box. Numeric.

  • "bbox_ymax". Maximum vertical coordinate of bounding box. Numeric.

  • "bbox_xmin". Minimum horizontal coordinate of bounding box. Numeric.

  • "bbox_xmax". Maximum horizontal coordinate of bounding box. Numeric.

Examples

# Geocode multiple addresses (top matches only)
## Not run: 
geocode_osm_batch(c("Ann Arbor","East Lansing","Columbus"))

## End(Not run)
# With progress reports
## Not run: 
geocode_osm_batch(c("Ann Arbor","East Lansing","Columbus"), verbose = TRUE)

## End(Not run)
# Return detailed results for all matches
## Not run: 
geocode_osm_batch(c("Ann Arbor","East Lansing","Columbus"),
                  details = TRUE, return_all = TRUE)

## End(Not run)

SUNGEO documentation built on Nov. 4, 2023, 1:07 a.m.