build_api_query: Helper Function to Build Queries to the Open Geography API

View source: R/build_api_query.R

build_api_queryR Documentation

Helper Function to Build Queries to the Open Geography API

Description

A function called by create_custom_lookup.R and geo_get.R to build a valid query.

Usage

build_api_query(ref, where_level, where = NULL, fields = "*", sr = 4326)

Arguments

ref

an integer, passed by the calling function, that indicates which url_string to use.

where_level

The variable name associated with the locations filter. e.g. "lsoa11nm" or "rgn20cd"

where

A vector of names or codes to filter the data by. If nothing is provided then the full table should be returned.

fields

The fields of the data to be returned. Defaults to "*" (all); can instead be a set of column names/variables.

sr

The (EPSG) spatial reference of any returned geometry. 4326 ("WGS 84") by default. Can be specified as numeric or character.

Value

a string that should function as a valid API query

Examples

build_api_query(ref = 4,
  where_level = "cauth20nm",
  where = "Greater Manchester",
  fields = c("lad20cd", "lad20nm", "cauth20cd", "cauth20nm")
)
build_api_query(ref = 12,
  where_level = "lad20nm",
  where = c(
    "Cheltenham", "Gloucester",
    "Stroud", "Cotswold",
    "Tewkesbury", "Forest of Dean"
  ),
  fields = c("lad20cd", "lad20nm")
)

francisbarton/jogger documentation built on Nov. 18, 2022, 2:46 p.m.