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 0a239a5563a344a3bbf8452504ed8d68.

Usage

morie_datasets_tps_community_safety_indicators(
  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

Community Safety Indicators (CSI) occurrences by reported date.

Tags: Community Safety Indicators; CSI; Crime; Toronto; TPS; Toronto Police

Examples

# \donttest{
df <- try(morie_datasets_tps_community_safety_indicators(max_features = 5L))
if (!inherits(df, "try-error")) head(df)
#>   OBJECTID EVENT_UNIQUE_ID  REPORT_DATE     OCC_DATE REPORT_YEAR REPORT_MONTH
#> 1        1  GO-20141260973 1.388552e+12 1.388552e+12        2014      January
#> 2        2  GO-20141260577 1.388552e+12 1.388552e+12        2014      January
#> 3        3  GO-20141260577 1.388552e+12 1.388552e+12        2014      January
#> 4        4  GO-20141260537 1.388552e+12 1.388552e+12        2014      January
#> 5        5  GO-20141264140 1.388552e+12 1.388552e+12        2014      January
#>   REPORT_DAY REPORT_DOY REPORT_DOW REPORT_HOUR OCC_YEAR OCC_MONTH OCC_DAY
#> 1          1          1 Wednesday            4     2014   January       1
#> 2          1          1 Wednesday            4     2014   January       1
#> 3          1          1 Wednesday            4     2014   January       1
#> 4          1          1 Wednesday            4     2014   January       1
#> 5          1          1 Wednesday           20     2014   January       1
#>   OCC_DOY    OCC_DOW OCC_HOUR DIVISION
#> 1       1 Wednesday         4      NSA
#> 2       1 Wednesday         2      NSA
#> 3       1 Wednesday         2      NSA
#> 4       1 Wednesday         4      NSA
#> 5       1 Wednesday        20      D53
#>                                           LOCATION_TYPE PREMISES_TYPE UCR_CODE
#> 1 Streets, Roads, Highways (Bicycle Path, Private Road)       Outside     2130
#> 2 Streets, Roads, Highways (Bicycle Path, Private Road)       Outside     1610
#> 3 Streets, Roads, Highways (Bicycle Path, Private Road)       Outside     1610
#> 4 Streets, Roads, Highways (Bicycle Path, Private Road)       Outside     1430
#> 5   Single Home, House (Attach Garage, Cottage, Mobile)         House     1430
#>   UCR_EXT            OFFENCE CSI_CATEGORY HOOD_158    NEIGHBOURHOOD_158
#> 1     210         Theft Over   Theft Over      NSA                  NSA
#> 2     180 Robbery - Swarming      Robbery      NSA                  NSA
#> 3     200  Robbery - Mugging      Robbery      NSA                  NSA
#> 4     100            Assault      Assault      NSA                  NSA
#> 5     100            Assault      Assault      100 Yonge-Eglinton (100)
#>   HOOD_140    NEIGHBOURHOOD_140 LONG_WGS84 LAT_WGS84
#> 1      NSA                  NSA    0.00000   0.00000
#> 2      NSA                  NSA    0.00000   0.00000
#> 3      NSA                  NSA    0.00000   0.00000
#> 4      NSA                  NSA    0.00000   0.00000
#> 5      100 Yonge-Eglinton (100)  -79.40008  43.70547
# }