A comprehensive data analytics platform for Toronto municipal datasets
Toronto Smart City Insights is an advanced analytics platform that transforms raw municipal data into actionable insights for city planning and public safety. The platform integrates crime indicators, 311 service requests, and traffic data to provide comprehensive visualizations, temporal analysis, and correlation insights through an interactive Streamlit dashboard.
Key Value Propositions:
- π― Data-Driven Decision Making: Transform 30,000+ municipal records into actionable insights
- π Interactive Analytics: Real-time filtering and visualization across multiple datasets
- πΊοΈ Geospatial Intelligence: Interactive maps with crime heatmaps, service request density, and traffic patterns
- π Temporal Analysis: Identify seasonal patterns, trends, and correlations over time
- π₯ Export Capabilities: Download filtered data and analysis results in multiple formats
- Integrate Municipal Data Sources: Combine crime, 311, and traffic datasets into a unified platform
- Enable Interactive Exploration: Provide intuitive tools for data exploration and analysis
- Generate Actionable Insights: Identify patterns and correlations for city planning decisions
- Ensure Data Quality: Implement robust cleaning and validation pipelines
- Facilitate Data Export: Enable stakeholders to download and use processed data
- City Planners: Strategic resource allocation and policy development
- Public Safety Officials: Crime pattern analysis and prevention strategies
- Data Analysts: Municipal data exploration and research
- Citizens & Researchers: Transparent access to city data and insights
| Dataset | Records | Time Period | Key Metrics |
|---|---|---|---|
| Crime Indicators | 9,785 | 2014-2019 | Incident types, locations, temporal patterns |
| 311 Service Requests | 9,999 | 2023 | Service categories, response times, neighbourhood distribution |
| Traffic Data | 14,135 | 1997-2024 | Volume counts, collision data, monitoring locations |
| Neighbourhood Boundaries | 158 | Current | Spatial boundaries, demographic context |
- Overall Completeness: 93.4% across all datasets
- Coordinate Coverage: 66.7% (Crime: 100%, Traffic: 100%, 311: 0%)
- Temporal Coverage: 27-year span with varying density
- Spatial Coverage: All 158 Toronto neighbourhoods represented
- Python 3.13: Latest language features and performance improvements
- Streamlit: Interactive web application framework
- Pandas & NumPy: Data manipulation and numerical computing
- GeoPandas: Geospatial data processing and analysis
- Plotly: Interactive visualizations and charts
- Folium: Interactive web maps and geospatial visualization
- Data Cleaning: Automated pipelines with validation and standardization
- Geospatial Processing: Coordinate validation, neighbourhood assignment
- Temporal Analysis: Time series processing and pattern detection
- Statistical Analysis: Correlation analysis with significance testing
- Interactive Maps: Multi-layer maps with toggle controls
- Statistical Charts: Temporal trends, correlations, and distributions
- Export Formats: CSV, JSON, Excel, Parquet with metadata
- Real-time Filtering: Dynamic data exploration capabilities
- Python 3.13 or higher
- Git for version control
- 4GB+ RAM recommended for large dataset processing
-
Clone the Repository
git clone <repository-url> cd smart-city-insights
-
Set Up Virtual Environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
# Fix NumPy 2.x compatibility (if needed) python fix_numpy_compatibility.py # OR install manually pip install 'numpy>=1.24.0,<2.0.0' pip install -r requirements.txt pip install -r dashboard/requirements.txt
-
Run Data Processing Pipeline
python src/run_full_cleaning.py python src/run_comprehensive_eda.py
-
Launch Dashboard
python launch_dashboard.py # OR streamlit run dashboard/app.py -
Access Application
- Open browser to
http://localhost:8501 - Navigate through the 5 dashboard tabs
- Use sidebar filters to explore data
- Open browser to
- KPI Metrics: Total incidents, requests, and monitoring points
- Temporal Trends: Monthly patterns across all datasets
- Neighbourhood Analysis: Top areas by incident type
- Correlation Summary: Cross-dataset relationships
- Interactive Maps: Multi-layer visualization with toggle controls
- Crime Heatmaps: Density visualization of incident locations
- 311 Density Maps: Service request choropleth by neighbourhood
- Traffic Hotspots: Monitoring locations with volume indicators
- Spatial Statistics: Coverage metrics and data quality indicators
- Monthly Analysis: Incident patterns over time
- Seasonal Patterns: Spring, Summer, Fall, Winter distributions
- Weekday Analysis: Day-of-week incident patterns
- Hourly Patterns: Time-of-day analysis (when available)
- Chart Export: Multiple formats (PNG, HTML, SVG, PDF)
- Neighbourhood Correlations: Statistical relationships between datasets
- Temporal Correlations: Time-series correlation analysis
- Cross-Dataset Analysis: 311 vs Crime relationship analysis
- Statistical Testing: P-value calculation and significance assessment
- Custom Analysis: User-defined dataset pairs and aggregation methods
- Filtered Datasets: Apply filters and export subsets
- Analysis Results: Download correlation matrices and insights
- Multiple Formats: CSV, JSON, Excel, Parquet support
- Metadata Inclusion: Timestamps and provenance tracking
- Real-time Preview: Data filtering with immediate feedback
- Crime Indicators: Peak activity varies by neighbourhood and season
- 311 Requests: Higher volume during business hours and weekdays
- Traffic Data: Consistent monitoring with volume-based patterns
- Crime Hotspots: Concentrated in specific neighbourhoods with identifiable patterns
- Service Requests: Distributed across city with neighbourhood-specific needs
- Traffic Monitoring: Comprehensive coverage with volume-based prioritization
- Crime vs Traffic: Moderate negative correlation (-0.592) at neighbourhood level
- 311 vs Crime: Weak correlation with statistical analysis available
- Temporal Alignment: Seasonal patterns vary across datasets
- Coordinate Completeness: Crime and Traffic data have full geospatial coverage
- Temporal Coverage: Varying time periods require careful analysis alignment
- Neighbourhood Assignment: 100% coverage for spatial analysis capabilities
- Resource Allocation: Data-driven deployment of services and personnel
- Policy Development: Evidence-based policy creation using historical patterns
- Performance Monitoring: Track service delivery and public safety metrics
- Budget Planning: Optimize spending based on neighbourhood-specific needs
- Crime Prevention: Identify high-risk areas and temporal patterns
- Response Optimization: Improve emergency response based on historical data
- Community Engagement: Transparent data sharing with residents
- Trend Analysis: Monitor long-term safety improvements
- Automated Processing: Scalable pipelines for ongoing data integration
- Quality Assurance: Comprehensive validation and cleaning procedures
- Export Capabilities: Flexible data access for downstream analysis
- Visualization Tools: Ready-to-use charts and maps for reporting
smart-city-insights/
βββ π data_raw/ # Original datasets from Toronto Open Data
βββ π data_cleaned/ # Processed and validated datasets
β βββ π maps/ # Generated interactive maps
β βββ π plots/ # Analysis visualizations
β βββ π analysis_insights.json # Comprehensive analysis results
βββ π src/ # Core processing modules
β βββ π data_cleaner.py # Data cleaning and validation
β βββ π geo_processor.py # Geospatial processing
β βββ π analysis_engine.py # Statistical analysis
β βββ π mapping_engine.py # Interactive map generation
β βββ π test_*.py # Comprehensive test suite
βββ π dashboard/ # Streamlit web application
β βββ π app.py # Main dashboard application
β βββ π spatial_components.py # Map and spatial visualizations
β βββ π temporal_components.py # Time series analysis
β βββ π correlation_components.py # Statistical analysis
β βββ π export_components.py # Data export functionality
βββ π notebooks/ # Jupyter analysis notebooks
β βββ π 01_data_cleaning_comprehensive.ipynb
β βββ π 02_geospatial_mapping.ipynb
β βββ π 03_comprehensive_eda.ipynb
βββ π requirements.txt # Python dependencies
- Data Processing Tests: Validation of cleaning and transformation pipelines
- Geospatial Tests: Coordinate validation and neighbourhood assignment
- Analysis Tests: Statistical computation and correlation analysis
- Dashboard Tests: UI components and interactive functionality
- Export Tests: File format generation and data integrity
- Test Coverage: 100% of core functionality tested
- Data Validation: Multi-stage validation with error reporting
- Performance Testing: Optimized for datasets up to 50,000 records
- Cross-Platform: Tested on macOS, Windows, and Linux environments
# Quick start for development
python launch_dashboard.py- Push to GitHub: Ensure all code is committed and pushed
- Connect Repository: Link GitHub repo to Streamlit Cloud
- Configure Settings: Set Python version to 3.13
- Deploy: Automatic deployment with requirements.txt
- Custom Domain: Optional custom domain configuration
# Dockerfile example (create as needed)
FROM python:3.13-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8501
CMD ["streamlit", "run", "dashboard/app.py"]# Optional configuration
STREAMLIT_SERVER_PORT=8501
STREAMLIT_SERVER_ADDRESS=0.0.0.0
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false- Dashboard User Guide: Complete walkthrough of all features
- Data Export Guide: Instructions for downloading and using data
- Analysis Methodology: Statistical methods and interpretation
- Troubleshooting Guide: Common issues and solutions
- API Reference: Function and class documentation
- Data Schema: Dataset structure and field definitions
- Processing Pipeline: Step-by-step data transformation process
- Deployment Guide: Production deployment instructions
- Methodology Report: Statistical approaches and validation methods
- Data Quality Report: Completeness, accuracy, and coverage analysis
- Performance Benchmarks: Processing times and optimization results
- Future Enhancements: Roadmap for additional features
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Run tests (
python -m pytest src/test_*.py) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
- Python Style: Follow PEP 8 with Black formatting
- Documentation: Comprehensive docstrings for all functions
- Testing: Unit tests for all new functionality
- Type Hints: Use type annotations for better code clarity
This project is licensed under the MIT License - see the LICENSE file for details.
- Toronto Open Data Portal: Primary data source for all municipal datasets
- City of Toronto: Original data collection and maintenance
- Statistics Canada: Neighbourhood boundary definitions
- OpenStreetMap: Base map tiles for interactive visualizations
- Toronto Open Data team for comprehensive municipal datasets
- Streamlit community for excellent documentation and examples
- Python geospatial community for robust processing libraries
- Contributors and testers who helped improve the platform
- Developer: [Your Name]
- Email: [your.email@example.com]
- LinkedIn: [Your LinkedIn Profile]
- GitHub: [Your GitHub Profile]
- Issues: Report bugs and request features via GitHub Issues
- Discussions: Join community discussions for questions and ideas
- Documentation: Comprehensive guides available in
/docsfolder - Email Support: Direct email for deployment and integration questions
- Live Demo: [Streamlit Cloud URL when deployed]
- Portfolio: [Your Portfolio Website]
- Case Study: [Detailed project case study link]
- Presentation: [Project presentation slides]
Built with β€οΈ for Toronto's Smart City Initiative
Transforming municipal data into actionable insights for better city planning and public safety.