geocode_osm: Geocode addresses with OpenStreetMap

View source: R/geocode_osm.R

geocode_osmR Documentation

Geocode addresses with OpenStreetMap

Description

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

Usage

geocode_osm(
  query,
  match_num = 1,
  return_all = FALSE,
  details = FALSE,
  user_agent = NULL
)

Arguments

query

Address or place name to be geocoded. Character string.

match_num

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

return_all

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

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.

Details

Note that Nominatim Usage Policy stipulates an absolute maximum of 1 request per second (https://operations.osmfoundation.org/policies/nominatim/). For batch geocoding of multiple addresses, please use geocode_osm_batch.

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 an address (top match only)
## Not run: 
geocode_osm("Michigan Stadium")

## End(Not run)
# Return detailed results for top match
## Not run: 
geocode_osm("Michigan Stadium", details=TRUE)

## End(Not run)
# Return detailed results for all matches
## Not run: 
geocode_osm("Michigan Stadium", details=TRUE, return_all = TRUE)

## End(Not run)

zhukovyuri/SUNGEO documentation built on Nov. 5, 2023, 1:07 p.m.