UK Bicycle Theft in Major Cities 2017 to 2020

Revisiting UK’s bicycle thefts. The data comes from https://data.police.uk/. The date ranged used was from May 2017 through April 2020. All surrounding police forces were used to obtain a comprehensive list of bicycle theft incidents. Previous post from 2016 can be found here. Carto was used to render the maps. Cities include: London, Manchester, Birmingham, and Bristol

London Click to enlarge 3.12 mb

London Click to enlarge 3.73 mb

Manchester Click to enlarge 1.07 mb

Birmingham Click to enlarge 706 kb

Bristol Click to enlarge 656 kb

If you would like to create your own UK crime maps, and are frustrated at the way data.police.uk presents its data. You may use this simple C# console application to aggregate it yourself. Simply paste the downloadables into a directory called LONDON4, and use the script below to generate an output file containing incidents from multiple police forces. Cheers.

C# Console Application

string dirPath = @"C:\LONDON4\";
List dirs = new List(Directory.EnumerateDirectories(dirPath));
Dictionary<string, int> dictUniqueCrime = new Dictionary<string, int>();
foreach (var dir in dirs)
{
    Console.WriteLine("{0}", dir.Substring(dir.LastIndexOf("\\") + 1));
    string filepath = @"C:\LONDON4\";
    filepath += dir.Substring(dir.LastIndexOf("\\") + 1);
    Console.WriteLine(filepath);
    string line;
    string[] fileEntries = Directory.GetFiles(filepath);
    foreach (string fileName in fileEntries)
    {
        Console.WriteLine(fileName);
        System.IO.StreamReader file =
            new System.IO.StreamReader(fileName);
        while ((line = file.ReadLine()) != null)
        {
            string[] parts = line.Split(',');
            string month = parts[1];
            string longitude = parts[4];
            string latitude = parts[5];
            string crimetype = parts[9];
            if (crimetype == "Bicycle theft")
            {
                string lines = month + "-1, " + longitude + ", " + latitude + "";
                System.IO.StreamWriter file1 = new System.IO.StreamWriter("C:\\Airplanes\\____BRITISHBICYCLES.csv", true);
                file1.WriteLine(lines);
                file1.Close();
            }
        }
        file.Close();
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *