Extract crime areas within a polygon

ukp_crime_poly(poly_df, date = NULL, ...)

Arguments

poly_df

dataframe containing the lat/lng pairs which define the boundary of the custom area. If a custom area contains more than 10,000 crimes, the API will return a 503 status code. ukp_crime_poly converts the dataframe into lat/lng pairs, separated by colons: lat,lng:lat,lng:lat,lng. The first and last coordinates need not be the same — they will be joined by a straight line once the request is made.

date,

Optional. (YYY-MM), limit results to a specific month. The latest month will be shown by default. e.g. date = "2013-01"

...

further arguments passed to or from other methods. For example, verbose option can be added with ukp_api("call", config = httr::verbose()). See more in ?httr::GET documentation https://cran.r-project.org/web/packages/httr/ and https://cran.r-project.org/web/packages/httr/vignettes/quickstart.html.

Note

further documentation here: https://data.police.uk/docs/method/crime-street/

Examples

library(ukpolice) # with 3 points poly_df_3 = data.frame(lat = c(52.268, 52.794, 52.130), long = c(0.543, 0.238, 0.478)) ukp_data_poly_3 <- ukp_crime_poly(poly_df_3)
#> No encoding supplied: defaulting to UTF-8.
head(ukp_data_poly_3)
#> # A tibble: 6 x 12 #> category persistent_id date lat long street_id street_name context id #> <chr> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr> <chr> #> 1 anti-soc… "" 2018… 52.3 0.496 1141362 On or near… "" 6349… #> 2 anti-soc… "" 2018… 52.3 0.497 1141337 On or near… "" 6349… #> 3 anti-soc… "" 2018… 52.3 0.476 1140354 On or near… "" 6351… #> 4 anti-soc… "" 2018… 52.3 0.413 557698 On or near… "" 6351… #> 5 anti-soc… "" 2018… 52.3 0.413 564411 On or near… "" 6351… #> 6 anti-soc… "" 2018… 52.2 0.484 561970 On or near… "" 6352… #> # ... with 3 more variables: location_type <chr>, location_subtype <chr>, #> # outcome_status <chr>
# with 4 points poly_df_4 = data.frame(lat = c(52.268, 52.794, 52.130, 52.000), long = c(0.543, 0.238, 0.478, 0.400)) ukp_data_poly_4 <- ukp_crime_poly(poly_df = poly_df_4)
#> No encoding supplied: defaulting to UTF-8.
head(ukp_data_poly_4)
#> # A tibble: 6 x 12 #> category persistent_id date lat long street_id street_name context id #> <chr> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr> <chr> #> 1 anti-soc… "" 2018… 52.3 0.413 557698 On or near… "" 6351… #> 2 anti-soc… "" 2018… 52.3 0.495 1141325 On or near… "" 6349… #> 3 anti-soc… "" 2018… 52.3 0.496 1141362 On or near… "" 6349… #> 4 anti-soc… "" 2018… 52.1 0.441 1135446 On or near… "" 6349… #> 5 anti-soc… "" 2018… 52.7 0.275 998436 On or near… "" 6349… #> 6 anti-soc… "" 2018… 52.1 0.443 1137028 On or near… "" 6349… #> # ... with 3 more variables: location_type <chr>, location_subtype <chr>, #> # outcome_status <chr>