๐ง Traffic Profile Analysis ๐ฆ
This module cleans, processes, and clusters time series traffic data for integration into simulation tools.
Author: Belรฉn Lรณpez Salamanca
Date: [11-07-2025]
Version: 1.0.0
- ๐ Project Overview
- ๐ Data Collection
- ๐งผ Data Cleaning and Preparation
- ๐ง Clustering Analysis
- Cluster Description
- Clustered Time Series Plot
- Map of Routes
- Cluster Membership by Route
- ๐ Notes & References
- ๐ฎ Next Steps
๐ Data Collection¶
Traffic data was captured from https://traficosevilla.es/, which provides hourly traffic counts for various monitored routes in the city of Seville. The data spans a full 24-hour period and was exported in two segments: morning (00โ12h) and afternoon (12โ24h).
๐งผ Data Cleaning and Preparation¶
The raw CSV files were read and cleaned using Python. Key steps included:
- Replacing missing values (
'-') with zeros (Later, those were deleted for clustering) - Merging the two halves of the day into a single unified 24-hour profile per route.
- Joining metadata such as route names from a separate CSV file containing route identifiers and street names.
There are 90 main roads determined by the Ayuntamiento but only the data of 46 roads are saved!
๐ง Time Series Clustering¶
We applied K-Means clustering to the time series data of vehicle counts per hour per route.
- The series were normalized to allow pattern-based grouping rather than scale-based.
- A total of 3 clusters were chosen based on visual validation and interpretability. At first glance it was clear that the data was split in 3 groups.
๐ Clustered Time Series and Cluster Description¶
| Cluster | Description |
|---|---|
| 0 | Medium traffic routes with regular daily rhythm |
| 1 | High-traffic routes with sharp morning peaks |
| 2 | Low-volume |
Below is the plot of all routes, colored by cluster membership. Each line represents a route's hourly traffic profile. Thicker lines show the average pattern for each cluster.

๐บ๏ธ Map of Routes¶
The following map visualizes the spatial distribution of the routes, overlaid with cluster color coding:
๐ Cluster Membership by Route¶
Cluster 0¶
| RUTAS | Calle |
|---|---|
| 1 | PALMERA_ENTRADA |
| 2 | PALMERA_SALIDA |
| 5 | LUIS_MONTOTO_ENTRADA |
| 6 | LUIS_MONTOTO_SALIDA |
| 7 | KANSAS_CITY_ENTRADA |
| 8 | KANSAS_CITY_SALIDA |
| 9 | JIMENEZ_BECERRIL_ENTRADA |
| 10 | JIMENEZ_BECERRIL_SALIDA |
| 11 | CRISTO.EXPIRACIรN_ENTRADA |
| 12 | CRISTO.EXPIRACIรN_SALIDA |
| 18 | TAMARGUILLO_SUR.-_NORTE-SUR |
| 21 | VIRGEN_DE_LUJAN_-_SUR-NORTE |
| 22 | VIRGEN_DE_LUJAN_-_NORTE-SUR |
| 24 | R.HISTORICA-_NORTE-SUR |
| 25 | PASEO_COLON_-_NORTE-SUR |
| 26 | PASEO_COLON_-_SUR-NORTE |
| 45 | AVDA._PAZ_ENTRADA |
| 46 | PUENTE_DE_LAS_DELICIAS_ENTRADA |
| 47 | PUENTE_DE_LAS_DELICIAS_SALIDA |
| 50 | TAMARGUILLO_NORTE_-_SUR-NORTE |
| 51 | TAMARGUILLO_NORTE_-_NORTE-SUR |
| 53 | TORNEO_-_SUR-NORTE |
| 59 | MARTINEZ.BARRIOS_-_SUR-NORTE |
| 89 | MENENDEZ_PELAYO_-_SUR-NORTE |
| 90 | MENENDEZ_PELAYO_-_NORTE-SUR |
Cluster 1¶
| RUTAS | Calle |
|---|---|
| 72 | R.NORTE(SECTOR_ESTE)_-_NORTE-SUR |
| 73 | R.NORTE(SECTOR_OESTE)_-_ESTE-OESTE |
| 74 | R.NORTE(SECTOR_OESTE)_-_OESTE-ESTE |
| 81 | CTRA._UTRERA_ENTRADA |
Cluster 2¶
| RUTAS | Calle |
|---|---|
| 13 | REP._ARGENTINA_ENTRADA |
| 14 | REP._ARGENTINA_SALIDA |
| 17 | TAMARGUILLO_SUR.-_SUR-NORTE |
| 19 | SU_EMINENCIA_-_SUR-NORTE |
| 20 | SU_EMINENCIA_-_NORTE-SUR |
| 30 | BORBOLLA_-_NORTE-SUR |
| 32 | EDUARDO_DATO_SALIDA |
| 33 | DR._FEDRIANI_ENTRADA |
| 34 | DR._FEDRIANI_SALIDA |
| 38 | RONDA_TRIANA_-_NORTE-SUR |
| 39 | RONDA_TRIANA_-_SUR-NORTE |
| 42 | CTRA._CARMONA_SALIDA |
| 43 | CTRA._CARMONA_ENTRADA |
| 78 | CARLOS_III_-_SUR-NORTE |
| 83 | RONDA_PIO_XII_-_OESTE-ESTE |
| 84 | RONDA_PIO_XII_-_ESTE-OESTE |
| 87 | CARDENAL_ILUNDAIN_-_OESTE-ESTE |
| 88 | CARDENAL_ILUNDAIN_-_ESTE-OESTE |
๐ฎ Next Steps¶
- ๐งน Interpolation: Fill in any minor gaps or missing values more intelligently than simple zeroing.
- ๐ Data enrichment: Coordinate with David to access historical or higher-resolution data.
- ๐ Integration with SUMO: Translate cluster-based traffic profiles into SUMO simulations using flows or OD matrices.
๐ Notes & References¶
- Raw traffic data: https://traficosevilla.es/
- Preprocessing and clustering done using
pandas,scikit-learn, andmatplotlib. - Optional interactive visualization made with
plotly.