Title: | Access the 'City of Vancouver' Open Data API |
---|---|
Description: | Wrapper around the 'City of Vancouver' Open Data API <https://opendata.vancouver.ca/api/v2/console> to simplify and standardize access to 'City of Vancouver' open data. Functionality to list the data catalogue and access data and geographic records. |
Authors: | Jens von Bergmann |
Maintainer: | Jens von Bergmann <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.8 |
Built: | 2024-11-16 05:06:06 UTC |
Source: | https://github.com/mountainmath/vancouvr |
Get aggregates from dataset from Vancouver Open Data Portal
aggregate_cov_data( dataset_id, select = "count(*) as count", group_by = NULL, where = NULL, apikey = getOption("VancouverOpenDataApiKey"), refresh = FALSE )
aggregate_cov_data( dataset_id, select = "count(*) as count", group_by = NULL, where = NULL, apikey = getOption("VancouverOpenDataApiKey"), refresh = FALSE )
dataset_id |
Dataset id from the Vancouver Open Data catalogue |
select |
select string for aggregation, default is 'count(*) as count' It accepts ODSQL syntax. |
group_by |
grouping variables for the query It accepts ODSQL syntax. |
where |
Query parameter to filter data (default 'NULL' no filter) It accepts ODSQL syntax. |
apikey |
Vancouver Open Data API key, default 'getOption("VancouverOpenDataApiKey")' |
refresh |
refresh cached data, default 'FALSE“ |
tibble format data table output
# Count all parking tickets that relate to fire hydrants by ticket status ## Not run: aggregate_cov_data("parking-tickets-2017-2019", group_by = "status", where = "infractiontext LIKE 'FIRE'") ## End(Not run)
# Count all parking tickets that relate to fire hydrants by ticket status ## Not run: aggregate_cov_data("parking-tickets-2017-2019", group_by = "status", where = "infractiontext LIKE 'FIRE'") ## End(Not run)
Get datasets from Vancouver Open Data Portal
get_cov_data( dataset_id, select = "*", where = NULL, apikey = getOption("VancouverOpenDataApiKey"), rows = NULL, cast_types = TRUE, refresh = FALSE, ... )
get_cov_data( dataset_id, select = "*", where = NULL, apikey = getOption("VancouverOpenDataApiKey"), rows = NULL, cast_types = TRUE, refresh = FALSE, ... )
dataset_id |
Dataset id from the Vancouver Open Data catalogue |
select |
select string for fields to return, returns all fields by default. It accepts ODSQL syntax. |
where |
Query parameter to filter data (default 'NULL' no filter) It accepts ODSQL syntax. |
apikey |
Vancouver Open Data API key, default 'getOption("VancouverOpenDataApiKey")' |
rows |
Maximum number of rows to return (default 'NULL' returns all rows) |
cast_types |
Logical, use metadata to look up types and type-cast automatically, default 'TRUE' |
refresh |
refresh cached data, default 'FALSE“ |
... |
optional ignored parameters, for compatibility with previous versions that relied on the 'format' parameter |
tibble or sf object data table output, depending on whether the dataset is spatial and 'cast_types' is 'TRUE'
# Get all parking tickets issued at the 1100 block of Alberni Street between 2017 and 2019 ## Not run: get_cov_data("parking-tickets-2017-2019",where = "block = 1100 AND street = 'ALBERNI ST'") ## End(Not run)
# Get all parking tickets issued at the 1100 block of Alberni Street between 2017 and 2019 ## Not run: get_cov_data("parking-tickets-2017-2019",where = "block = 1100 AND street = 'ALBERNI ST'") ## End(Not run)
Get metadata for CoV open data dataset
get_cov_metadata( dataset_id, apikey = getOption("VancouverOpenDataApiKey"), refresh = FALSE )
get_cov_metadata( dataset_id, apikey = getOption("VancouverOpenDataApiKey"), refresh = FALSE )
dataset_id |
the CoV open data dataset id |
apikey |
the CoV open data API key, optional |
refresh |
refresh cached data, default 'FALSE“ |
tibble format data table output
# Get the metadata for the street trees dataset ## Not run: get_cov_metadata("street-trees") ## End(Not run)
# Get the metadata for the street trees dataset ## Not run: get_cov_metadata("street-trees") ## End(Not run)
Download the CoV open data catalogue
list_cov_datasets( trim = TRUE, apikey = getOption("VancouverOpenDataApiKey"), refresh = FALSE )
list_cov_datasets( trim = TRUE, apikey = getOption("VancouverOpenDataApiKey"), refresh = FALSE )
trim |
trim all NA columns, optional, defaul 'TRUE' |
apikey |
the CoV open data API key, optional |
refresh |
refresh cached data, default 'FALSE“ |
tibble format data table output
# List and search available datasets ## Not run: list_cov_datasets() ## End(Not run)
# List and search available datasets ## Not run: list_cov_datasets() ## End(Not run)
Search for CoV open data datasets
search_cov_datasets( search_term, trim = TRUE, apikey = getOption("VancouverOpenDataApiKey"), refresh = FALSE )
search_cov_datasets( search_term, trim = TRUE, apikey = getOption("VancouverOpenDataApiKey"), refresh = FALSE )
search_term |
grep string to serach through datasets |
trim |
trim all NA columns, optional, defaul 'TRUE' |
apikey |
the CoV open data API key, optional |
refresh |
refresh cached data, default 'FALSE“ |
tibble format data table output
# search available datasets relating to trees ## Not run: search_cov_datasets("trees") ## End(Not run)
# search available datasets relating to trees ## Not run: search_cov_datasets("trees") ## End(Not run)