Skip to content

Tools for retrieving ONS ward boundaries and obtaining monthly data.police.uk street-level crimes per ward

Notifications You must be signed in to change notification settings

instantiator/ward-level-crime-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voting ward crime data

Voting ward boundaries are slightly different from policing ward boundaries, for pragmatic reasons.

This process allows us to generate boundaries we can pass to data.police.uk to collect a cut of crime data per ward per month.

Just here for the data?

Take a look inside the 2018-05 boundaries folder - you'll find subfolders for the data that has been retrieved.

  • london_month_YYYY_MM - a folder for London data. JSON files contain crime data for each London ward in the given month.
  • UK_month_YYYY_MM - a folder for UK data. JSON files contain crime data for every UK ward in the given month.

Repository structure

  • /READ.md - this README.
  • /.gitignore - mainly to prevent accidental inclusion of large KML files in this repository.
  • /ward identities/Wards - wards.csv - comma separated ward identity data (id, ward name, ward area)
  • /ward identities/Wards - wards.tsv - tab separated ward identity data (id, ward name, ward area)
  • /2018-05 boundaries/london_ward_ids_only.csv - a list of ids (one per line) for the wards in London (ostensibly CSV).
  • /2018-05 boundaries/ward boundary processing.workbook - fetches crime data for the whole of the UK for a given month.
  • /2018-05 boundaries/london wards processing.workbook - fetches crime data for all London wards across a range of months.

Fetching ward boundaries

Boundaries were updated (provisionally) in May 2018, so we'll use the latest boundaries from ONS.

Download and place the KML file for these boundaries in the 2018-05 boundaries folder.

Retrieving crime data per ward

You will need to install:

The Xamarin Workbooks inside the 2018-05 boundaries folder manage retrieval of crime data.

To fetch your own subset of the data, open the appropriate workbook, update the initial variables, and use Ctrl+R to run.

Please note, at time of writing there are 9114 wards across the UK with ~13000 boundaries defined (as some wards have multiple boundaries). The process of extracting crime data for a given month can take a considerable amount of time!

Notes on ward boundaries

Our ward boundaries are wrapped in KML and not in the format we'll need to generate requests to the data.police.uk APIs.

First we'll extract the boundary data per ward, then we'll use that to POST a request to data.police.uk and retrive a JSON file with details of all crime in a given month for that ward.

NB:

  • The data.police.uk API cannot handle complex ward boundaries by GET, but you may submit a full boundary in POST.
  • The poly parameter for the API is counter-intuitively arranged: LNG:LAT,LNG:LAT,LNG:LAT,etc.
  • The month parameter is formatted: YYYY-MM (as you might expect)

Understanding crime data

Please see the street-level crime endpoint page at data.police.uk for the range of categories and information you can retrieve:

About

Tools for retrieving ONS ward boundaries and obtaining monthly data.police.uk street-level crimes per ward

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published