NYC Traffic Centrality is an interactive web portal for exploring traffic patterns in New York City. It applies AGNES hierarchical clustering to traffic data to find the city's real traffic hubs, then shows them as colour-coded markers on a React and Leaflet map that can be filtered by date and time.
Built during an Object/IoT Technologies workshop.
The question#
Raw traffic counts tell you where there are a lot of cars. They don't tell you which locations are central — the intersections the rest of the network depends on, where congestion spreads outward. Answering that means treating traffic as a network problem: intersections are nodes, flows between them are edges, and centrality scores reveal which nodes matter most.
The second half of the challenge was making the answer readable by people who don't think in graphs. A table of centrality scores is correct and useless; a map where the hubs glow red is something anyone can read.
What it does#
- Interactive map — zoom and pan across New York City, and click any marker for details
- Time filters — filter by year, month, day and time slot, such as the morning and evening rush
- Colour-coded clusters — clustering output maps to a scale from green (low centrality) to red (high centrality)
- Detail popups — each marker shows its centrality score, cluster and raw traffic counts
- Multiple languages — the interface is available in English and French
- Responsive layout — usable on desktop and tablet
How it works#
The project is split into an offline data pipeline and a static frontend. Heavy computation happens once, in Python; the browser only ever loads the result.
The data pipeline#
Raw NYC traffic data (CSV)
│
▼
Preprocessing (pandas)
- filter and clean records
- aggregate by intersection
- compute centrality scores
│
▼
AGNES clustering
- hierarchical agglomerative clustering
- grouped into centrality levels (very low → very high)
│
▼
clustered_traffic.jsonAGNES (AGglomerative NESting) is a bottom-up hierarchical clustering algorithm. It starts with every location as its own cluster, then repeatedly merges the two closest clusters until the desired number remains. Unlike k-means, it doesn't need random initial centres and produces a full hierarchy, which makes it a good fit for grouping locations into ordered levels of centrality.
The frontend#
clustered_traffic.json
│
React state (filtered view)
│
Leaflet markers (colour by cluster)
│
Popup (centrality score + raw counts)The React app loads the pre-clustered JSON and renders each location as a Leaflet marker whose colour comes from its cluster level. Filtering by date and time slot happens client-side, so changing a filter updates the map instantly with no server round-trip.
Key challenges#
Large datasets#
NYC traffic data is large, and clustering is expensive. Running it in the browser — or on every request — was never an option. Pre-processing in Python means the cost is paid once, and the frontend receives a compact JSON file containing only what it needs to draw.
Thousands of markers#
Rendering thousands of markers on a map can make panning and zooming stutter. Keeping the marker components lightweight, deriving the filtered view from state instead of re-creating the map, and loading pre-computed data kept interaction smooth.
Readable for non-experts#
The colour scale was the most important design decision. Five ordered levels from green to red map directly to "how central is this place", and the popup is there for anyone who wants the numbers behind the colour.
Running it#
git clone https://github.com/ismailza/Traffic-Centrality
cd Traffic-Centrality
# Run the data pipeline
cd python && pip install -r requirements.txt && python cluster.py
# Start the frontend
cd frontend && npm install && npm startOr with Docker:
docker compose up --build
# Frontend: http://localhost:3000Results#
- An interactive map that handles thousands of data points smoothly
- AGNES clustering surfaces centrality patterns that are invisible in raw counts
- Multi-language support for a broader audience
Team#
Built with Khaoula ABASSI, Mohamed JEBBANEMA and El Mehdi Salah BEN SOUDA.
Centralization and Classification of New York City Traffic
Overview
In a collaborative effort, the Kolmogorov Team presents the Centralization and Classification of New York City Traffic project. Developed as part of the Object/IoT Technologies workshop, this advanced web portal is crafted to analyze and visualize traffic centrality within the bustling urban landscape of New York City.
Leveraging the power of React and Leaflet for responsive map rendering, our portal introduces an innovative approach to visualizing traffic flow and connectivity across diverse locations. The core of our system is powered by the AGNES (Agglomerative Nesting) algorithm, enabling sophisticated data classification, segmentation, and enhanced visualization of centrality metrics. This integration not only boosts user engagement but also sharpens the analytical depth, offering nuanced insights into the city's structural dynamics.
Features
- Dynamic map visualization with zoom and pan functionalities.
- Filterable data based on year, month, day, and time slots.
- Color-coded clusters to represent different traffic flows.
- Detailed information on traffic flow accessible via map markers.
- Responsive design for optimal viewing on desktop and mobile devices.
- Multi-language support for a global audience.
Technologies Used
This project stands at the intersection of modern web development and advanced data science, leveraging a stack that combines the responsiveness of web interfaces with the computational power of data analysis algorithms.
Frontend Development
- React: A JavaScript library for building user interfaces.
- Leaflet: An open-source JavaScript library for mobile-friendly interactive maps.
- react-leaflet: React components for Leaflet maps.
- Material-UI: Provides a suite of beautifully designed UI components that enhance the application's aesthetics and user experience.
- Bootstrap: Offers a responsive design library that ensures the application looks great on all devices.
- i18next: A powerful internationalization framework for translating web applications into multiple languages.
Data Analysis and Clustering
- Python: Serves as the backbone for implementing data analysis algorithms, benefiting from a rich ecosystem of libraries for numerical and scientific computing.
- AGNES (Agglomerative Nesting): At the core of our data classification strategy, AGNES enables hierarchical clustering by calculating similarities between observations.
- Python Libraries: Leveraged powerful libraries such as pandas for data manipulation and scikit-learn for implementing the AGNES algorithm.
Data Handling and Integration
- JavaScript: Employed to process CSV files, calculate centrality metrics, and generate JSON outputs. This allows for seamless integration of analyzed data into our web application, making the results of clustering algorithms accessible and interactive.
- JSON: Serves as the interchange format, enabling the structured representation of clustering results and centrality data for visualization in the web application.
Implementation Insights
Utilizing Python for implementing the AGNES algorithm afforded us access to robust libraries like pandas and scikit-learn, which are indispensable for data analysis. These libraries provided us with the tools necessary to implement our algorithm from scratch, import data, calculate similarities between street observations, and perform hierarchical clustering of streets into meaningful clusters.
Deployment
Our application is containerized for easy deployment using Docker. Here’s how you can pull the Docker image from Docker Hub and run it locally.
Prerequisites
Docker installed on your machine. See the official Docker documentation for installation instructions.
Pulling the Docker Image
To pull the latest version of the Docker image for our application from Docker Hub, run the following command in your terminal:
docker pull ismailza/traffic-centrality:latestRunning the Docker Container
After pulling the image, you can run the application as a Docker container using the following command:
docker run -d -p 5173:5173 ismailza/traffic-centrality:latestContinuous Integration and Deployment
Our project utilizes GitHub Actions for Continuous Integration and Deployment (CI/CD), automating the process of building and pushing the Docker image to Docker Hub upon each push to the main branch. This ensures that the latest version of our application is always available for deployment.
For more details on our CI/CD setup, refer to the .github/workflows/docker-deploy.yml file in our repository.
The Team
This endeavor is a collaborative effort by a group of classmates: Ismail ZAHIR, Khaoula ABASSI, Mohamed JEBBANEMA and El Mehdi Salah BEN SOUDA. As students in the same class, we combined our expertise and enthusiasm to create a tool that offers insightful visualizations about the significance and connectivity of different locations worldwide.
Acknowledgments
We extend our heartfelt thanks to our teachers, who have guided us through this project with their wisdom and patience. We are grateful for the opportunity to learn and grow under their mentorship.
License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License Copyright (c) 2024 Ismail ZAHIR Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
