query_api: Execute a geocoder API query

Description Usage Arguments Value See Also Examples

View source: R/query_factory.R

Description

The get_api_query function can create queries for this function to execute.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
query_api(
  api_url,
  query_parameters,
  mode = "single",
  batch_file = NULL,
  input_list = NULL,
  content_encoding = "UTF-8",
  timeout = 20,
  method = ""
)

Arguments

api_url

Base URL of the API. query parameters are appended to this

query_parameters

api query parameters in the form of a named list

mode

determines the type of query to execute

- "single": geocode a single input (all methods)
- "list": batch geocode a list of inputs (ex. geocodio)
- "file": batch geocode a file of inputs (ex. census)
batch_file

a csv file of input data to upload (for mode = 'file')

input_list

a list of input data (for mode = 'list')

content_encoding

Encoding to be used for parsing content

timeout

timeout in minutes

method

if 'mapquest' or 'arcgis' then the query status code is changed appropriately

Value

a named list containing the response content (content) and the HTTP request status (status)

See Also

get_api_query extract_results extract_reverse_results geo reverse_geo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
raw1 <- query_api("http://nominatim.openstreetmap.org/search", 
   get_api_query("osm", list(address = 'Hanoi, Vietnam')))
   
raw1$status
   
extract_results('osm', jsonlite::fromJSON(raw1$content))

raw2 <- query_api("http://nominatim.openstreetmap.org/reverse", 
   get_api_query("osm", custom_parameters = list(lat = 38.895865, lon = -77.0307713)))
   
extract_reverse_results('osm', jsonlite::fromJSON(raw2$content))

tidygeocoder documentation built on Nov. 3, 2021, 1:08 a.m.