get_theme {onemapsgapi} | R Documentation |
Get Theme Data from OneMap.Sg
Description
This function is a wrapper for the Retrieve Theme API. It returns the data as cleaned tibbles.
Usage
get_theme(
token,
theme,
extents = NULL,
return_info = FALSE,
return_spatial = FALSE
)
Arguments
token |
User's API token. This can be retrieved using |
theme |
OneMap theme in its |
extents |
Optional, Location Extents for search. This should be in the format "Lat1,%20Lng1,Lat2,%20Lng2". For more information, consult the API Documentation. |
return_info |
Default = |
return_spatial |
Default = |
Value
If no error occurs:
- query_info
A 1 x 7 tibble containing information about the query. The variables are
FeatCount
,Theme_Name
,Category
,Owner
,DateTime.date
,DateTime.timezone_type
,DateTime.timezone
- query_result
Returned if return_info =
TRUE
. A tibble containing the data retrieved from the query. The columns and rows vary depending on theme and user specification, however all tibbles will contain the variables:NAME
,DESCRIPTION
,ADDRESSPOSTALCODE
,ADDRESSSTREETNAME
,Lat
,Lng
,ICON_NAME
If an error occurs, an error will be raised, along with the API's error message and status code.
For non-error queries where 0 results are returned, the output will be query_info
, along with a warning message.
Examples
# returns a tibble of output
## Not run: get_theme(token, "hotels")
## Not run: get_theme(token, "monuments",
extents = "1.291789,%20103.7796402,1.3290461,%20103.8726032")
## End(Not run)
# returns a sf dataframe
## Not run: get_theme(token, "hotels", return_spatial = TRUE)
# returns a list of status tibble and output tibble
## Not run: get_theme(token, "funeralparlours", return_info = TRUE)
# error: throws an error with error message and status code
## Not run: get_theme("invalid_token", "hotels")
# error: throws an error with error message and status code
## Not run: get_theme(token, "non-existent-theme")
# error: output is \code{query_info}, warning message query did not return any records
## Not run: get_theme(token, "ura_parking_lot", "1.291789,%20103.7796402,1.3290461,%20103.8726032")