# Modeling and Optimization of NO2 Stations in the Smart City of Barcelona
## 4 Methodology
### Descriptive Analysis  
A detailed analysis of the measured NO\({}_{2}\) concentrations across the city is conducted to identify and observe patterns over different time frames, including daily and weekly behavior. Various graphical representations are created to explore the temporal dynamics of NO\({}_{2}\) concentrations [37].  
First, daily averages are analyzed to examine general trends in NO\({}_{2}\) behavior, investigating daily and weekly variability, showing the influence of traffic emissions and weather conditions [38]. Additionally, weekly patterns are explored to identify potential cyclical behaviors influenced by factors such as urban mobility and industrial activity. Finally, a spatial analysis is then conducted to distinguish the behavior of NO\({}_{2}\) concentrations at individual monitoring stations. This approach examines the spatial and temporal representativeness of NO\({}_{2}\) monitoring stations in urban settings, highlighting the importance of capturing local variations to obtain a complete picture of air quality [39]. The analysis is further complemented by using meteorological variables obtained from stations distributed throughout the city. A wind rose is generated to visualize and understand the predominant wind directions and speeds in the city. This tool is essential for identifying local climate patterns and variations in different parts of the city [40]. This analysis helps in understanding how meteorological conditions contribute to the dispersion of atmospheric pollutants,  
Figure 1: Spatial distribution of air quality stations (red) and meteorological stations (green).  
highlighting the influence of urban climates on air quality [41]. Additionally, integrating meteorological data with air quality models is crucial to obtain a more accurate view of pollutant dispersion in urban areas [42].  
As the final step of the descriptive analysis, a cluster analysis is performed to study the behavior of NO\({}_{2}\) concentrations at the monitoring stations. The hourly average values of NO\({}_{2}\) concentrations at each station during the study period are used to identify common patterns among the stations [43]. For this analysis, the K-means algorithm is selected, which requires specifying the number of clusters in advance [44]. To determine the optimal number of clusters, the elbow method is employed [45]. This method involves plotting the number of clusters against inertia (the sum of squared distances within each cluster), and the point where a significant change in the inertia decrease occurs indicates the optimal number of clusters. In addition, agglomerative hierarchical clustering is applied, a method that does not require specifying the number of clusters initially [46]. This algorithm treats each point as an individual cluster and successively merges the closest clusters, creating a hierarchical structure. The result is represented by a dendrogram, where the branches indicate the clusters, and the height of each union reflects the Euclidean distance [47]. In our study, the Euclidean distance is used as the metric that captures the separation between points in an n-dimensional space, providing a clear representation of how NO\({}_{2}\) concentrations vary according to the location of the monitoring stations.