One-call TPS PSDP data + boundary metadata join
Source:R/datasets_tps_psdp.R
morie_datasets_tps_psdp_resolved.RdPhase 3CCC3. Pulls a TPS PSDP crime dataset
(morie_datasets_tps_assault() etc.) and left-joins its native
DIVISION + HOOD_158 + HOOD_140 columns against the bundled
boundary metadata loaders (morie_datasets_tps_police_divisions(),
morie_to_neighbourhoods() 158 + 140 + NIA flags) and the PSDP
layer registry (morie_tps_psdp_layers()).
Usage
morie_datasets_tps_psdp_resolved(
layer_key,
year = NULL,
max_features = NULL,
offline = TRUE,
layer_url = NULL,
resolvers = c("division", "hood158", "hood140", "nia", "psdp_class")
)Arguments
- layer_key
One of the PSDP
layer_keys frommorie_tps_psdp_layers()(e.g.,"assault","autotheft","homicides").- year
Optional year filter passed through to the underlying loader.
- max_features
Optional row cap.
- offline
If
TRUE(default), all data come from bundled fixtures.- layer_url
Backward-compat override for non-canonical FeatureServer URL.
- resolvers
Character subset of
c("division", "hood158", "hood140", "nia", "psdp_class"). Default joins all five.
Details
Per-row PSDP datasets carry these ID columns natively:
DIVISION(e.g., "D11") – joins to police_divisions.DIVHOOD_158(integer 1-158) – joins to 158-neighbourhoodsNEIGHBOURHOOD_158(denormalised name)HOOD_140(integer 1-140) – joins to 140-neighbourhoodsNEIGHBOURHOOD_140(denormalised name)
Resolver columns are prefixed division_*, hood158_*,
hood140_*, nia_*, psdp_* to avoid collisions. Left-join
semantics (row count preserved).
Mirrors the Chicago morie_datasets_chicago_crime_resolved()
(3VV+) and NYPD morie_datasets_nyc_nypd_resolved() (3AAA-3CCC1)
patterns.
Examples
df <- morie_datasets_tps_psdp_resolved("assault", offline = TRUE)
names(df)
#> [1] "HOOD_158" "HOOD_140"
#> [3] "DIVISION" "OBJECTID"
#> [5] "EVENT_UNIQUE_ID" "REPORT_DATE"
#> [7] "OCC_DATE" "REPORT_YEAR"
#> [9] "REPORT_MONTH" "REPORT_DAY"
#> [11] "REPORT_DOY" "REPORT_DOW"
#> [13] "REPORT_HOUR" "OCC_YEAR"
#> [15] "OCC_MONTH" "OCC_DAY"
#> [17] "OCC_DOY" "OCC_DOW"
#> [19] "OCC_HOUR" "LOCATION_TYPE"
#> [21] "PREMISES_TYPE" "UCR_CODE"
#> [23] "UCR_EXT" "OFFENCE"
#> [25] "CSI_CATEGORY" "NEIGHBOURHOOD_158"
#> [27] "NEIGHBOURHOOD_140" "LONG_WGS84"
#> [29] "LAT_WGS84" "x"
#> [31] "y" "division_OBJECTID"
#> [33] "division_AGENCY" "division_UNIT_NAME"
#> [35] "division_ADDRESS" "division_CITY"
#> [37] "division_AREA_SQKM" "division_Shape__Area"
#> [39] "division_Shape__Length" "hood158__id"
#> [41] "hood158_AREA_ID" "hood158_AREA_ATTR_ID"
#> [43] "hood158_PARENT_AREA_ID" "hood158_AREA_LONG_CODE"
#> [45] "hood158_AREA_NAME" "hood158_AREA_DESC"
#> [47] "hood158_CLASSIFICATION" "hood158_CLASSIFICATION_CODE"
#> [49] "hood158_OBJECTID" "hood140__id"
#> [51] "hood140_AREA_ID" "hood140_AREA_ATTR_ID"
#> [53] "hood140_PARENT_AREA_ID" "hood140_AREA_LONG_CODE"
#> [55] "hood140_AREA_NAME" "hood140_AREA_DESC"
#> [57] "hood140_CLASSIFICATION" "hood140_CLASSIFICATION_CODE"
#> [59] "hood140_OBJECTID" "nia_is_nia"
#> [61] "nia_area_name" "psdp_class_key"
#> [63] "psdp_class_label" "psdp_class_hub_id"