Skip to contents

Toronto PS ArcGIS Hub dataset wrapper. Thin dispatch to morie_datasets_tps_arcgis_hub_by_id() with the canonical hub item_id bc4c72a793014a55a674984ef175a6f3.

Usage

morie_datasets_tps_traffic_collisions(
  format = "json",
  where = "1=1",
  max_features = NULL,
  layer_idx = 0L,
  offline = TRUE,
  dest = NULL
)

Arguments

format

One of "json" (default), "geojson", "csv", "shapefile", "fgdb".

where

SoQL-style WHERE filter passed to FeatureServer ?where= (default "1=1").

max_features

Optional cap on returned rows. Passed as resultRecordCount to FeatureServer; ignored for binary formats.

layer_idx

Integer index of the FeatureServer layer to pull (default 0L, the first layer).

offline

Logical; if TRUE, the hub_id is resolved via the included catalog (no network needed for the resolution step). Default TRUE – you can run this against the 71 catalog entries without network. Live data fetches always hit the network regardless of this argument; "offline" here only affects the hub_id -> FeatureServer URL lookup.

dest

Optional path for binary downloads (format %in% c("shapefile", "fgdb")); defaults to tempfile().

Value

A data.frame / GeoJSON list / file path; see morie_datasets_tps_arcgis_hub_by_id() for per-format semantics.

Details

Collision occurrences by occurrence date.

Tags: Traffic; Collision; Traffic Collisions; Motor Vehicle Collisions; Toronto; TPS; Toronto Police

Examples

# \donttest{
df <- try(morie_datasets_tps_traffic_collisions(max_features = 5L))
if (!inherits(df, "try-error")) head(df)
#>   OBJECTID EVENT_UNIQUE_ID     OCC_DATE OCC_MONTH   OCC_DOW OCC_YEAR OCC_HOUR
#> 1        1  GO-20148000014 1.388552e+12   January Wednesday     2014       19
#> 2        2  GO-20148000012 1.388552e+12   January Wednesday     2014       18
#> 3        3  GO-20141260499 1.388552e+12   January Wednesday     2014        2
#> 4        4  GO-20141260663 1.388552e+12   January Wednesday     2014        3
#> 5        5  GO-20141261162 1.388552e+12   January Wednesday     2014        5
#>   DIVISION FATALITIES INJURY_COLLISIONS FTR_COLLISIONS PD_COLLISIONS HOOD_158
#> 1      D33          0                NO            YES            NO      042
#> 2      D41          0                NO             NO           YES      126
#> 3      NSA          0               YES             NO            NO      NSA
#> 4      NSA          0                NO             NO           YES      NSA
#> 5      NSA          0               YES             NO            NO      NSA
#>        NEIGHBOURHOOD_158 LONG_WGS84 LAT_WGS84 AUTOMOBILE MOTORCYCLE PASSENGER
#> 1 Banbury-Don Mills (42)  -79.35748  43.75349        YES         NO        NO
#> 2      Dorset Park (126)  -79.28110  43.76582        YES         NO        NO
#> 3                    NSA    0.00000   0.00000        YES         NO        NO
#> 4                    NSA    0.00000   0.00000        YES         NO        NO
#> 5                    NSA    0.00000   0.00000        YES         NO        NO
#>   BICYCLE PEDESTRIAN
#> 1      NO         NO
#> 2      NO         NO
#> 3      NO         NO
#> 4      NO         NO
#> 5      NO         NO
# }