This project provides a set of Python scripts to fetch, analyze, and visualize crime data from the police.uk API. It includes tools to generate interactive maps, heatmaps, and dashboards for crime data in the UK.
- Interactive Crime Maps: Generate HTML maps with markers for individual crime and stop-and-search incidents.
- UK-Wide Heatmap: Create a heatmap to visualize crime density across the entire UK.
- Hampshire Crime Dashboard: A detailed, interactive dashboard for Hampshire, including analytics, charts, and a map.
- Data Caching: Scripts cache data locally to avoid repeated API calls.
- KML Boundary Support: Use KML files to define geographical boundaries for data fetching.
Below is a screenshot of the Crime Dashboard for Hampshire:
create_crime_map.py: Creates an interactive crime map for Hampshire.create_crime_map_UK.py: Creates a clustered crime map for the entire UK.create_heatmap.py: Generates a UK-wide crime heatmap from cached data.hampshire_crime_dashboard.py: Generates an interactive HTML dashboard for Hampshire.crime_dashboard.py: A simple script for a basic crime breakdown in a specific area.get_polygon_from_kml.py: A utility to extract coordinates from KML files.
-
Prerequisites:
- Python 3
pandasfoliumrequestsmatplotlib
-
Installation:
pip install pandas folium requests matplotlib
-
Directory Structure:
boundaries/: Store your KML files in this directory. The scripts expect a subdirectory for each police force (e.g.,boundaries/hampshire/).cached_data/: This directory is created automatically to store cached API responses.
-
Running the Scripts:
- To generate the Hampshire crime map:
python create_crime_map.py
- To generate the UK-wide crime map:
python create_crime_map_UK.py
- To generate the UK crime heatmap:
python create_heatmap.py
- To generate the Hampshire crime dashboard:
python hampshire_crime_dashboard.py
- To generate the Hampshire crime map:
This project uses data from the police.uk API.
This project is licensed under the MIT License - see the LICENSE file for details.
