Crime Map
TableauPythonAPIs
A comprehensive analysis of crime rates across London districts using public police data. Includes interactive maps and trend analysis to identify high-risk areas.
Overview
After recently moving into the Newham district in London, I wanted to see which areas had the highest crime rates. Therefore, this dashboard deep-dives into the crime rates and statistics.
Key Features
- Interactive maps showing crime hotspots
- Temporal analysis of crime patterns
- Breakdown by crime types and districts
- Demographic correlation analysis
- Trend forecasting and seasonal patterns
Technologies Used
- Python for data processing and analysis
- Tableau for interactive visualizations
- UK Police API for data collection
- Pandas for data manipulation
- GeoPandas for spatial analysis
Data Collection Process
import requests
import pandas as pd
# API Configuration
base_url = "https://data.police.uk/api"
endpoint = "/crimes-street/all-crime"
# Define Area Parameters
params = {
"poly": "51.507222,-0.127647:51.522420,-0.102827:51.517814,-0.076428:51.487366,-0.068504:51.477458,-0.096115:51.498466,-0.119421",
"date": "2021-01",
"polyname": "london",
"page": 1
}
# Fetch Crime Data
dfs = []
while True:
response = requests.get(f"{base_url}{endpoint}", params=params)
# Check response status
if response.status_code != 200:
print(f"Request failed with status code {response.status_code}")
break
# Process data
data = response.json()
if not data:
break
dfs.append(pd.json_normalize(data))
params["page"] += 1
# Save Collected Data
all_data = pd.concat(dfs)
all_data.to_csv("police-data-uk.csv", index=False)
# Optional: Display Data Summary
print(f"Total crime records collected: {len(all_data)}")
print(f"Unique crime categories: {all_data['category'].nunique()}")