README.md

winnipegr Travis build status

This R package provides an abstraction layer for easily accessing openly available data sets for Winnipeg, MB, Canada.

Installation

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")

Retrieving Data

The package includes the following functions for downloading open data:

| DESCRIPTIVE | get_open_data | ARGUMENT STRINGS | | ------------ | ----------------- | ----------------- | | "2018 polling geoms" | "park assets" | "transit on-time hist" | | "311" | "parking" | "transit pass-ups" | | "311 channels" | "parking bans" | "transport mode" | | "address coords" | "parking citations" | "trees" | | "air quality" | "parks" | "TSI-bases detail trans" | | "boundary" | "permit details" | "TSI-cameras detail" | "building permits" | "plow schedule" | "TSI-corridor box indications detail" | | "burials" | "population" | "TSI-corridor boxes detail" | | "by-law investigations" | "public notices" | "TSI-hardware detail" | | "capex" | "river james" | "TSI-heads (displays) detail" | | "collection days" | "river levels" | "TSI-locations" | | "contravention" | "school enrolments" | "TSI-pole and arms detail" | | "council expenses" | "survey parcel" | "TSI-pole and cabinet locations" | | "dispositions" | "tax parcels" | "TSI-traffic signal malfunctions" | | "fipa requests" | "ticket adjudication results" | "TSI-traffic signal damage" | | "lane closures" | "TMC-confirmed incidents" | "waste tonnage" | | "mosquito traps" | "transit on-time" | "web analytics" |

The package also contains internal fixed data sets. Load these data sets in the usual way data(transport_mode). Currently included data sets:

Examples

get_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{
    get_weather(station = "forks",
        start = '2018-01-01',
        end = '2018-02-28',
        metric = TRUE)
    get_weather(station = "airport",
        start = '2018-01-01')
}

search_open_data

This function uses the jsonlite package to get and search/grep current metadata on the data sets available on the City of Winnipeg Open Data site data.winnipeg.ca. It returns a data frame with descriptions of data, and code to retrieve data sets using get_open_data, or through the open data Socrata API.

\dontrun{
    # Returns all metadata as a data frame
    search_open_data()

    # Examines data sets whose title or description contains 'trees'
    # ignoring case
    search_open_data('trees')

    # Get recently updated data sets
    search_open_data(updated_after = '2019-01-01')

    # Return API short codes for searched data sets
    search_open_data(contains = 'parking')$identifier[1]
}

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)

    get_open_data("river james")

    get_open_data(search_open_data("clerk")$identifier[1])
}

get_transit

This function uses the jsonlite 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)
}


jdallmann/winnipegr documentation built on Jan. 20, 2020, 2:05 a.m.