knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This R package provides an abstraction layer for easily accessing openly available data sets for Winnipeg, MB, Canada.
In the future, you will be able to install the released version of winnipegr from CRAN with:
install.packages("winnipegr")
But, for now you need to use devtools
:
install.packages("devtools") devtools::install_github("jdallmann/winnipegr")
The package includes the following functions for downloading open data:
wpg_weather
for sourcing Winnipeg weather from stations from: Winnipeg 'CXWI', Winnipeg Forks 'CXWN', and Winnipeg International Airport 'CYWG'.get_WPA_Stations
for sourcing available WPA parking station variables such as available_space
, hourly_rate
, timelimit
, location, and others.get_open_data
a wrapper for calling City of Winnipeg open data (https://data.winnipeg.ca/) using descriptive data set identifiers. This includes particularly rich Traffic Signal Inventory (TSI) data. The data is provided under the Open Government Licence – Canada. Available options include:
get_transit
provies a wrapper for making calls to the Winnipeg Transit APIs, and flattens the result into a tidy dataframe. Requires an API key available from https://api.winnipegtransit.com/home/api/v3. Currently available API type
options include:
The package also contains internal fixed data sets. Load these data sets in the usual way data(transport_mode)
. Currently included data sets:
transport_mode
Mode of transportation data from Statistics Canada's 2016 Census. (See: City of Winnipeg open data.)census_commute_2019
Census commute data from Statistics Canada for Winnipeg CMA 2019 at the DA level.wpg_electoral_wards_2018
Winnipeg electoral wards following 2018 election with shapefile geometries.neighbourhoods_2017
Boundaries of neighbourhood characterization areas (aka NCA) used to delineate neighbourhoods for city planning purposes.active_trans_ntwk_2019
Boundaries and data for Winnipeg's active transport cycling network.census_demo_2019
Data for key Winnipeg demographics information (100% data and total data from Statistics Canada). Data is at the finest geographical resolution (Dissemination Area---DA) available. Admittedly not complete, and based on variables of interest in my work.census_DA_2019
Boudary shape file with id for Statistics Canada 2019 DA data.wpg_weather
This function uses the reim
package to load Winnipeg
weather abstracting station names. Measurements have the option to
be converted to metric using the weathermetrics
package.
\dontrun{ wpg_weather(station = "forks", start = '2018-01-01', end = '2018-02-28', metric = TRUE) wpg_weather(station = "airport", start = '2018-01-01') }
get_open_data
This function uses the RSocrata
package to get Winnipeg
City data from the Winnipeg Open Data site data.winnipeg.ca
.
Users with a City of Winnipeg open data account can also use their
login credentials to have full (non-throttled) access to the API.
\dontrun{ get_open_data("parking", app_token = SOME_API_TOKEN, email = FAKE_EMAIL, password = FAKE_PASSWORD) \dontrun{ get_open_data("river James") }
get_transit
This function uses the rjson
package to get Winnipeg
City Transit data from the Winnipeg Transit API v3.
It also flattens that data from json to a tidy dataframe.
Users must have registered for their own (free) API key to use.
\dontrun{ get_transit(option_vec = c("lat=49.8951", "lon=-97.1384", "distance=1000", "walking=true", "usage=short"), api_key = transit_API) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.