# Analysis of Urban Residents' Travelling Characteristics and Hotspots Based on Taxi Trajectory Data
## 2 Materials and Methods
### HDBSCAN Algorithm Cluster Analysis  
The HDBSCAN algorithm, an advancement of the DBSCAN algorithm, is adept at clustering in areas with varying densities. The algorithm's operation includes the following:  
1. Matrix construction based on point distance.
2. The algorithm's operation includes the following:  
Figure 5: Schematic diagram of trajectory matching.  
Utilizing the spherical cosine law, the algorithm calculates the distance \(D_{ij}\) between two trajectory points with coordinates \((lat_{i},lon_{i})\) and \((lat_{j},lon_{j})\); \(R\) represents the radius of the earth, which is about 6371 km.  
\[D_{i,j}=cos^{-1}(sin(lat_{1})\times sin(lat_{2})+cos(lat_{1})\times cos(lat_{2})\]  
\[\times\cos(lon_{2}-lon_{1}))\times R \tag{4}\]  
This distance is then used to populate a symmetric matrix. Diagonal elements \(D_{i,j}\) are set to zero, representing the distance from a point to itself.  
Creation of a distance-weighted graph and minimum spanning tree (MST).  
Trajectory points are interconnected based on the distance matrix to form a distance-weighted graph. Starting from an appropriate edge, the algorithm finds the edge with the minimum weight that connects the tree to vertices not yet in the tree. This edge is then added to the tree, and the process is repeated until all vertices are included. This process is illustrated in Figure 6.  
Creation of an interconnectivity diagram.  
This step involves defining the minimum neighbor density threshold (MinPts) based on core distances. A dense area is formed when the number of neighbors in a cluster exceeds MinPts. The reachability distance is defined as the maximum of the core distance and the actual distance between two endpoints in the MST. If both endpoints are in high-density areas, the actual Euclidean distance is used; if one endpoint is in a low-density area, the larger core distance is chosen. The MST is then transformed into an interconnectivity graph based on this reachability distance.  
Construction of hierarchical clustering tree.  
Utilizing the interconnectivity graph, a hierarchical clustering tree is constructed, as presented in Figure 7. This tree represents the connections of data points at various levels, facilitating a comprehensive understanding of the clustering process from individual points to the entire database.  
Figure 6: Minimum tree diagram.  
(5)  
Simplification of the clustering tree hierarchy.  
The stability and duration of each cluster in the hierarchical tree are analyzed. Clusters with short durations or instability are eliminated, focusing on more distinct and stable data clusters.  
(6) Optimal clustering selection.  
The final clustering results are chosen based on cluster stability, ensuring that the selected clusters are of high quality and reliability.  
To demonstrate the effectiveness, part of the trajectory data are subjected to both DBSCAN and HDBSCAN clustering for comparison (Figure 8).  
The two clustering methods yield noise point detection proportions of 15.85% and 7.31%, respectively. This comparison highlights the superior noise reduction capability of  
Figure 8: Comparison of different aggregation results: (**a**) DBSCAN clustering; (**b**) HDBSCAN clustering.  
Figure 7: Hierarchical clustering tree connection diagram.  
the HDBSCAN algorithm. In Figure 8, we can observe that HDBSCAN clustering exhibits a higher point density, resulting in a more continuous clustering trajectory. This characteristic is advantageous for identifying residents' travel hotspots. On the other hand, DBSCAN clustering displays lower point density, causing the clusters to be more dispersed and making it challenging to visually identify high-density areas of trajectory points.