get_planning_areas {onemapsgapi} | R Documentation |
Get Planning Areas (All)
Description
This function is a wrapper for the Planning Area Polygons API. It returns the data either in raw format or a combined sf object.
Usage
get_planning_areas(token, year = NULL, return_spatial = FALSE)
Arguments
token |
User's API token. This can be retrieved using |
year |
Optional, check documentation for valid options. Invalid requests will are ignored by the API. |
return_spatial |
Optional, whether to return the result as a |
Value
If the parameter read
is not specified, the function returns a raw JSON object with planning names and geojson string vectors.
If return_spatial = TRUE
, the function returns a single "sf" tibble with 2 columns: "name" (name of planning area) and "geometry", which contains the simple features.
If an error occurs, the function throws an error with the API error message and status code.
Note
If the user specifies return_spatial = TRUE
but does not have the sf
package installed, the function will return the raw JSON and print a warning message.
Examples
# returns raw JSON object
## Not run: get_planning_areas(token)
## Not run: get_planning_areas(token, 2008)
# returns dataframe of class "sf"
## Not run: get_planning_areas(token, return_spatial=TRUE)
# error: output is NULL, warning message shows status code
## Not run: get_planning_areas("invalid_token")