Abstract
Given the large volume of georeferenced information generated and stored by many types of devices, the study and improvement of techniques capable of operating with these data is an area of great interest. The analysis of vehicular trajectories with the aim of forming clusters and identifying emerging patterns is very useful for characterizing and analyzing transportation flows in cities. This paper presents a new trajectory clustering method capable of identifying clusters of vehicular sub-trajectories in various sectors of a city. The proposed method is based on the use of an auxiliary structure to determine the correct location of the centroid of each group or set of sub-trajectories along the adaptive process. The proposed method was applied on three real databases, as well as being compared with other relevant methods, achieving satisfactory results and showing good cluster quality according to the Silhouette index.
Keywords
Technological advances have made it easy for devices to record information in various scenarios, giving rise to large volumes of data in very diverse formats. This has increased interest in techniques capable of analyzing such data to identify the most relevant features and to recognize relationships or emerging patterns that help decision making. For example, Kang et al. ( 1 ) developed an algorithm to extract significant places visited by individuals from a trace of coordinates originated from WiFi access points. In a different context, Li et al. ( 2 ) explored the similarity between users based on spatio-temporal location histories, using GPS data collected by 65 volunteers over a period of 6 months.
On many occasions, information arising from geographic positions could help in the definition of public policies related to urban growth or public services. In this context, the analysis of spatial data generated by the various location technologies used today is of vital importance for the elaboration of urban development plans for cities. Large volumes of these spatial data, produced by Geographic Information Systems (GIS), are used by governments in urban planning, transportation engineering, territorial analysis, and other areas ( 3 ). Within these systems, the spatial component is implemented with a specific geographic location.
Having strategies to identify common features in spatial data (geographic locations) has proven useful in different urban planning applications. For example, through the characterization of people’s mobility profiles, urban planning related to the management of recreational facilities can be improved. Additionally, this information could be used, for example, to plan commercial activities, promote car sharing systems, and, among other things, to evaluate driver behaviors as observed in this paper ( 4 ).
It is often also necessary to know the characteristics of regions or places and the moblity characteristics of entities. For example, to identify the most common origins and destinations or when these entities move in large numbers and where they stop. These two problems translate, respectively, into applications capable of characterizing regions (mainly the discovery of hot spots) and moving objects (mainly determining the mobility of people or other entities) ( 5 ).
Transportation systems also influence urban planning and development, since identifying congestion areas in a city, and the analysis of these areas, is vital to the future construction of transportation infrastructure or road corridors that improve mobility. In addition, developments in the transport sector demand increasingly efficient techniques for the analysis of spatial data.
Intelligent Transportation Systems (ITS) process large amounts of trajectory data generated from vehicles on the roads in real time (6–9). A trajectory is defined by a set of geographic locations, each of which is represented by its latitude and longitude, at a moment in time. Intelligent trajectory analysis can assist in assessing road performance regardless of the type of road (streets, highways, etc.), as evidenced in ( 10 ), which proposes a new methodology for solving the optimal roadway segment configuration problem.
The ITS has methods to perform traffic flow analysis in specific sectors of the city. These methods can be enhanced using additional information from the same system, for example the direction of the trajectory, the average speed of a group of vehicles in an specific time or the number of vehicles in a spatial-temporal location. This additional information can help to predict futures traffic jams, accidents, low traffic flow in some areas between other things, providing information to decision makeres, as evidenced in (11, 12), which discuss a clustering approach to assessing travel time variability. By contrast, ( 13 ) analyzes hot spots based on regions. One of the methods used in traffic analysis is segmentation ( 14 ). To facilitate this analysis a clustering method must be used. There are several methods in the bibliography with advantages and disadvantages but variables like precision and the quality of vehicular concentration groups can be improved.
In this research we analyze various clustering methods to compare the strategies used to create the groups and the similarity measures used to get the majority of the information. We present a novel clustering technique based on a pivot concept to enhance the quality of the groups in the clustering process. The proposal allows analysis of the clustering of trajectories within several sectors of a city. This analysis is useful when applied to road planning and can be enriched by considering other moving objects within a city.
The aim of this paper is to propose an alternative clustering method. This method is based on pivots and performs partitive clustering of vehicle trajectories, departing from the well-known K-means method (15, 16). The algorithm generates clusters given by the average trajectories (i.e., centroids) of each group. In this sense, the use of pivots is a fundamental tool for correctly identifying the closest group for each sub-trajectory. This directly affects the dispersion of elements within each group, as will be explained in the discussion of the results.
The method proposed in this article may be useful for traffic managers planning urban roads, reducing congestion levels, detecting hotspots, improving traffic flow, identifying anomalous traffic situations, and predicting future behaviors ( 17 ). Furthermore, better traffic flow management leads to environmental improvements. The algorithm was applied to three data sets with real, non-simulated data to guarantee the empirical validity of its performance.
This paper contributes to the existing literature in several ways: i) it proposes a trajectory segmentation phase based on the angles formed between two trajectory locations. The partitioning and generation of sub-trajectories depend on a threshold angular value; ii) it adds a mechanism for the selection of initial centroids with the definition of a lattice in the area to be analyzed; and iii) it proposes a trajectory clustering method that uses novel centroid recalculation by means of pivots.
The remainder of the paper is organized as follows: the first section discusses the related literature and presents alternative solutions to the problem under examination; we then describe the proposed trajectory clustering method using the pivot; this is followed by a description of the data used in the experiments; we then present and discuss the results obtained in the three data sets; finally, we draw conclusions and discuss possble future research lines.
Literature Review
Techniques used to analyze data are divided into two broad groups: those that operate on labeled information and those that do not. The first group corresponds to predictive models, while the second generates descriptive models. A predictive model offers a response to a new situation and is generated from the observation and generalization of the responses given in previous situations. In other words, to obtain one, it is necessary to know the answer or label from many previous cases. Descriptive models seek to identify similarities between the recorded data to identify situations or behaviors within a process without requiring prior labels. The analysis of trajectories presented in this paper belongs to the second type. The objective is to recognize similarities in the trajectories, considering not only the geographic locations involved but also other aspects related to specific situations, such as density changes. Such changes occur in congestion or under anomalous traffic patterns and are extremely useful for predicting accidents.
There are different techniques to build descriptive models, grouping or clustering being the most widely used ( 18 ). Currently, clustering techniques identify groups of instances with similar characteristics from which patterns or relationships can be extracted. They can be adapted to very diverse fields such as health, finance, telecommunications, agriculture, and transportation, among others ( 19 ).
Several researchers have attempted to address the limitations identified in certain techniques, such as Varghese et al. ( 3 ). Other researchers have modified existing techniques to apply them to specific contexts, such as spatial data mining (20, 21) and the analysis of trajectories ( 5 ).
The analysis of trajectories involves large volumes of data, which are usually processed incrementally, that is, as the data are recorded. This type of processing requires certain special considerations. An incremental clustering technique is proposed by Li et al. ( 22 ). It seeks to respond to this type of situation based on a strategy defined by Aggarwal et al. ( 23 ) to cluster data flows.
In the literature related to clustering techniques in the transport area, there are some contributions oriented to the analysis of transport flows in cities to improve urban planning (24, 25), while others are aimed at clustering trajectories ( 26 ). Some other papers discuss the clustering of trajectories in a road network environment. This problem can be solved by the combination of map matching and graph clustering algorithms. Other lines of research discuss methods for trajectories in free spaces ( 27 ).
Trajectory Clustering Algorithms
Classical clustering algorithms deal with vector data of fixed dimensions. Unlike these classical algorithms, trajectory clustering algorithms process information with different characteristics such as temporal sequential information and in some cases the length of these trajectory data is different within the same data set.
Gaffney and Smyth ( 28 ), using a probabilistic regression model, gave rise to one of the first density and distance-based approaches to trajectory clustering, these early clustering approaches used in analysis of trajectories make use of partitive and density-based algorithms ( 29 ). Partitive clustering algorithms gather observations or examples into several pre-specified clusters. These algorithms start from a random partition that is then refined by iterations, that is, moving an object from one cluster to another. K-means ( 16 ) is an example of this type of algorithm. Nanni ( 30 ) made an adaptation to make these algorithms capable of processing trajectories by using two classical distance-based clustering algorithms (the classical K-means algorithm and the hierarchical agglomerative method). Density-based algorithms start the cluster from one object, and the cluster grows as long as there are new objects in the neighborhood. The cluster is considered valid if the total number of objects exceeds a threshold. DBScan is a member of this algorithm family ( 31 ). Several papers adapt existing algorithms to a particular context using unconventional measures of similarity between trajectories (32–34). The Enhanced DBScan algorithm ( 35 ) improves on the traditional DBScan algorithm (36, 37) using its own density measurement method (movement capability), which relies on adjacent points along the trajectory. Additionally, it combines two consecutive stops with the same geographic location and a short time interval, using the method developed by Yuan and Raubal ( 34 ). The Tra-DBScan algorithm ( 38 ), based on the DBScan algorithm ( 31 ), adds a trajectory segmentation phase and partitions the trajectories into sections using the Hausdorff distance as the similarity measure. This metric considers the perpendicular, angular, and parallel distances of the different GPS points that are part of the trajectory segments. Ferreira et al. ( 39 ) introduce a new trajectory clustering technique that uses vector fields to represent the centers of the clusters and propose a definition of similarity between trajectories. The K-means vector field, while reminiscent of the K-means algorithm (40, 41), is a new formulation for trajectory clustering, with the ability to find global patterns that are not locally apparent in noisy trajectories or even partial trajectories. Additionally, the algorithm can be paralleled, allowing escalation into large data sets. Yu et al. ( 42 ) propose an improved trajectory model and present a new clustering algorithm that uses a measure of similarity based on multiple characteristics of the trajectories, thus maximizing their value when it comes to elements of the same group. Recently, Yang et al. ( 43 ) proposed a new trajectory clustering algorithm called TAD. Some of its main advantages are as follows i) it introduces a noise tolerance factor, which can dynamically evaluate and reduce the impact of noise in the algorithm execution process; ii) it integrates time and space features into a single measurement function to improve grouping accuracy; and iii) it builds a new density function, which accurately distinguishes different types of points in trajectories and finds trajectory stays based on space-time density data analysis. This algorithm also defines two new metrics: Motion Capability and Neighborhood Time (NMAST) and Noise Tolerance (NT). Another approach is based on segmentations or partitioning and proposes dividing the trajectories into segments before grouping them. Dividing them into segments makes it possible to analyze areas in a more specific way by identifying different places crossed by various trajectories (5, 44). TRACLUS clustering algorithm uses this second approach ( 45 ). Ailin et al. ( 46 ) also use the segmentation of trajectories at a specific time, making use of this technique to partition the trajectories according to the threshold given by the Minimum Description Length (MDL) principle and then employ a Density Peak Clustering (DPC) process which allows them to extract the trend of the trajectories’ movements. Zhou et al. ( 29 ) propose a clustering method that uses trajectory regressions and angle-based partitions to avoid getting stuck in local optima. The following papers have been identified among others also based on this approach (47–49). Another approach is to analyze road networks in conjunction with trajectories, Hong et al. ( 50 ) propose an algorithm that employs similar spatio-temporal clustering, which takes into consideration the topological relationships that make road networks. Yu ( 51 ) proposes a multilevel method in which network analysis and association rules are put together to efficiently obtain the movement patterns of trajectories. Feng et al. ( 52 ) take into account a static topology of road networks to create a directed weighted complex network, in which spatio-temporal changes over critical roads and intersections are identified. Niu et al. ( 53 ) also perform a similar approach using a road network through a dual graph model to identify the similarity between the nodes used. The development of these algorithms has given rise to new approaches that specialize mainly in making trajectory predictions using space-time techniques to consider the dynamic evolution of trajectories ( 54 ) used on large-scale data. Wang et al. ( 55 ) use the above scheme as a base and add the use of artificial intelligence models to classify the data and demonstrate the search potential on the resulting clusters. Tallapragada and Cortes ( 56 ) on the other hand, consider the coordination of traffic at intersections and determine clusters as they appear, trying to optimize the results for individual trajectories. To consider the dynamic nature of the data, some of this approach makes use of the characteristics of the created clusters themselves, as in the case of Huang et al. ( 57 ), who make use of additional information such as stopping and waiting times of vehicles to provide solutions to alleviate traffic at certain times. Tang et al. ( 58 ) analyze urban trajectories using a fusion of spatial, temporal, and directional attributes to provide traffic planning and management strategies. Kumar et al. ( 59 ) have focused on solving a problem that arises as these approaches evolve, which is the handling of a large-scale spatio-temporal data volume, proposing new more efficient distance measures and an algorithm to determine the number of optimal clusters, this could be applicable in those using data mining techniques obtained from big data, which will affect the performance of the algorithm employed as they will require more processing power to be viable; other alternatives use Markov chains ( 60 ) or R-trees ( 61 ) to create index structures that reduce the employed cost of time. Liu and Zhang ( 62 ) emphasize the importance of distance calculations to reveal differences between trajectories and promote higher accuracy of algorithms by adaptive selection of clusters and their characteristic features.
A full review of the object trajectory clustering algorithms exceeds the scope of this paper. We, therefore, refer to a recent review that surveys and summarizes recent trends on moving object clustering algorithms ( 63 ).
Trajectory Similarity Metrics
There are different clustering techniques for analyzing trajectory data. On the one hand, some use traditional similarity or distance metrics (e.g., Euclidean distance, Manhattan distance, etc.) to identify a trajectory and assign it to a specific cluster (64, 65). On the other, there are techniques that use non-traditional similarity metrics (66, 67).
An additional line of research proposes the use of a deep neural network (DNN) to develop a supervised similarity model ( 68 ). The similarity metrics considered in the literature include: distances limited by the network, distances based on form, and distances based on warping (66, 67). Network-limited distances use the underlying road network, and assume that the road network is known and that the trajectory data are perfectly mapped on it. Shape-based distances seek to identify the geometric characteristics of trajectories by emphasizing their shape. Distances based on warping take the temporal dimension into account.
Proposed Method: Trajectory Clustering Using Pivots
The present proposal uses the trajectory segmentation strategy introduced by Reyes et al. ( 44 ) and incorporates a pivot as a device to calculate the average trajectories (i.e., centroids) of each group. Thus, the proposed method is called K-pivot. An important aspect of any clustering method is the correct initialization of the centroids. In this paper, we propose setting a grid that encompasses all trajectories. Table 1 shows the notations used in this paper.
Notations
A trajectory is defined as a sequence of geographic positions, each represented by its latitude and longitude. In other words, the
A cluster is a set of sub-trajectories. A centroid is a sequence of geographic positions that represents or characterizes all the sub-trajectories of a cluster and can be written as
A pivot in this paper is defined as a line segment in the area where a majority of the sub-trajectories of a cluster are located. To obtain the direction of the pivot, the angles of each sub-trajectory with respect to the coordinate axis are averaged. The number of positions in the pivot coincides with the average number of positions that make up the sub-trajectories of the corresponding cluster. The pivot is a guide to the centroid recalculation process.
The trajectory clustering method consists of the following phases:
Segmentation
Grid setting
Clustering.
In the segmentation phase, the trajectory is divided into segments or portions called sub-trajectories. To perform the partitioning, an angular threshold is used as a tool to detect abrupt changes in direction. In this way, the sub-trajectories will not present abrupt changes in their routes, thus facilitating their subsequent processing.
Once the set of sub-trajectories has been obtained, the analysis area is partitioned by means of a grid. This is a grid determined a priori over the area to be analyzed. Once the regions are established, the initial position of the average individual or centroid of each group is fixed in each of them. The Hausdorff distance will be used to calculate the distance between sub-trajectories.
The central contribution of the method proposed in this paper is the introduction of pivots to improve the quality of the centroids as representatives of the sub-trajectories of each cluster.
Each of these stages is described in more detail below.
Segmentation
As previously mentioned, in this paper the trajectories were partitioned into segments of shorter length to facilitate their processing. This mechanism has been used in the literature in previous works (29, 47).
In this phase of the algorithm, the trajectories composed of geographic positions are partitioned, with the aim of generating small segments that have similar characteristics with respect to their shape and direction. The method used for this segmentation was developed by Reyes-Zambrano et al. ( 44 ). The aforementioned study analyzed the angles that form the lines, which link pairs of consecutive geographic positions within the trajectory, using the cartesian plane as a reference.
Initially, the absolute value of the difference between the first two angles of this sequence is calculated. If this difference does not exceed a certain threshold value determined a priori, called angular tolerance, both positions are considered to belong to the same sub-trajectory.
This process is repeated sequentially by calculating the absolute value of the difference between the first angle and the following angles in the list until a value that exceeds the threshold is found. When this occurs, the final position of the first sub-trajectory will have been determined. This position is considered to be the starting position for the next one. In this way, each trajectory is segmented into shorter routes so that no significant, sudden, or obvious changes with respect to its direction are observed.
Grid Setting
The square grid is a lattice that covers the area under study. Its use guarantees uniform coverage of the area in which the trajectories are located and it is employed to determine the initial position of the average representatives of each group. It is important to consider that the size of the lattice directly impacts the spatial granularity of the clustering, this being an aspect to be defined on the characteristics of the data set to be processed.
The initial centroids are computed by creating a rectilinear sub-trajectory, based on the mean positions of the sub-trajectories and vertices relative to each lattice cell in the lattice set. The initial 16 centroid sub-trajectories are plotted diagonally in each cell, as shown in Figure 1. These initial positions are not the only ones possible. We carried out experiments placing these centroids perpendicular, as shown in Figure 1, and it did not have a significant impact on the overall results. Therefore, within this investigation, it can be said that the use of any diagonal produces similar results.

Initial crosslinking and centroid sub-trajectories.
Clustering
The clustering algorithm is an adaptation of the K-means algorithm that operates with sub-trajectories. The new contribution consists of the incorporation of pivots to improve the representation of the centroid in relation to the sub-trajectories of the cluster. Its usefulness is based on the identification of the area in which most sub-trajectories are concentrated within each cell. Although it has a linear plot, its appropriate location within the cell pulls the centroid toward the most representative area.
Following Gao and Leung ( 69 ), in this paper, the Hausdorff distance was used as a similarity measure to assign each sub-trajectory to the closest cluster.
The Hausdorff metric measures the distance between two sub-trajectories of a metric space defined by Rockafellar and Wets ( 70 ). Its use is a result of the need to compare elements made up of several geographical positions.
The process begins with the assignment of each sub-trajectory to the nearest centroid. The initial location of the centroids was indicated immediately after the lattice definition as indicated in the grid setting section. As a result of this assignment process, the first distribution of the sub-trajectories in clusters is formed. From this point on, the sub-trajectories are processed in the context of each cluster. To draw the pivot, it is necessary to identify the area in which most of the sub-trajectories of the cluster are located as well as the main or representative direction of these sub-trajectories.
The plotted area is obtained by arranging the sub-trajectory positions of each group in increasing order in two different lists, one for latitude and one for longitude. The two lists containing all the sub-trajectory positions are divided equally, thus obtaining four lists. The average value of each of these lists is then calculated, generating the following metrics: upper half longitude, lower half longitude, upper half latitude, and lower half latitude.
In the figures, the horizontal axis is associated with longitude, while the vertical axis is associated with latitude.
These values determine four positions:

Pivot plot area.
In this way, the pivot is plotted in the area where a majority of the sub-trajectories of the cluster are located. The cluster sub-trajectory angles must be averaged to obtain the pivot direction.
Figure 3 exemplifies the angle

Angle formed by a sub-trajectory with respect to the abscissa axis.
The angle
Finally, the angles of all sub-trajectories of a cluster are averaged, thus obtaining the angle
The pivot trace depends on the sign of the angle. If the mean angle (

Pivot with: (a) negative; and (b) positive mean angle.
Then, Equation 2 determines the positions of the pivot, where
Each pivot is defined by a given number of positions belonging to the line segment within the previously defined plotting area. This number coincides with the average number of geographic positions that make up the sub-trajectories of the corresponding cluster.
Once the pivot is calculated, it is used as a guide to identify the positions of the sub-trajectories that, when averaged, result in a new centroid position.
Figure 5 shows how the positions are identified following the pivot line. In this figure,

Positions used to determine the centroid.
The process begins with the identification of the position belonging to the closest trajectory (
This position is denoted
Algorithm 1 summarizes the process described above. The stop or end condition of the algorithm is given by the convergence or stability of the centroids position.
Data
The proposed method was implemented in R Language and experiments were carried out on a PC with an Intel core i5-8250 CPU @ 1.60GHz, 8GB RAM, and 64-bit architecture. We ran the experiments on three data sets. The first data set was formed of a series of trajectories recorded by a group of students from the University of Guayaquil using their smartphones. (The Guayaquil dataset is available at https://github.com/gary-reyes-zambrano/Guayaquil-DataSet.git.) The second data set corresponds to a t-drive database and contains information on taxi tours of the city of Beijing (China) and was used by Yuan et al. (71, 72). (The Beijing dataset is available at https://www.microsoft.com/en-us/research/publication/t-drive-trajectory-data-sample/.) The third data set is from “Go! Track” app users in the city of Aracaju (Brazil) and was also used by Zhou et al. ( 73 ) and Tang et al. ( 74 ). (The Aracaju dataset is available at https://archive.ics.uci.edu/ml/machine-learning-databases/00354/.)
Guayaquil Data set
This data set is made up of movement trajectories of university students traveling by public and private means of transport such as taxis, motorcycles, and the metro. It was collected in the city of Guayaquil (Ecuador). It contains positions of approximately 218 users collected in the northern and central Guayaquil cells during October 2017. The positions in this data set were collected by mobile devices with an average time interval between two consecutive positions of 5 s. This data set was pre-processed to extract records from October 28 from 16:30 to 18:30 as during this period, there was the highest concentration of positions in the data set. After filtering, we obtained 30,557 records, representing 206 trajectories. The file format in the repository has the following fields: id trajectory, latitude, longitude, and time stamp (unix time). Figure 6 shows a representation of the data set on the map of the city of Guayaquil.

Geographic representation of the data set from Guayaquil.
Beijing Data Set
This data set consists of taxi tours in the city of Beijing (China). The data set comes from the t-drive project and contains the positions of 10,357 taxis collected in Beijing during February 2008. The positions in this data set were collected by taxi GPS devices with an average time interval between two consecutive positions of 177 s. This data set was pre-processed to extract the records from February 02 from 13:30 to 15:00 to focus the experiment within a certain time frame. After this filtering process, 62,138 records were obtained, representing 630 trajectories. The file formats in the repository are as follows: trajectory id, date-time, longitude, and latitude. A representation of the Beijing city map is shown in Figure 7.

Geographic representation of the data set from Beijing.
Aracaju Data Set
The third data set consists of car and bus user routes recorded through the “Go! Track” app in the city of Aracaju (Brazil). The data set includes trajectories collected in Aracaju from September 13, 2014 to January 19, 2016. The positions in this data set were collected with high time variability between two consecutive positions. This data set was pre-processed to extract the records from September 13, 2014, 07:24:32 to July 23, 2015, 09:27:51. After filtering, 14,096 records were obtained representing 137 trajectories. The format of the files in the repository are as follows: id, latitude, longitude, and track_id, time. A representation of the data set on the city map of Aracaju is shown in Figure 8.

Geographic representation of the data set from Aracaju.
Obtained Results
The central contribution of the K-pivot clustering technique proposed in this paper lies precisely in the use of a pivot. Its performance was compared with two existing solutions in the literature: the clustering of trajectories using the K-means method adapted for trajectories (in this work is called K-centroids) and a density-based clustering using the Tra-DBScan method.
During the iterative update process of the K-centroid algorithm, each sub-trajectory is directly compared with the previous centroid and then recalculated. As for Tra-DBScan, it uses the concept of neighborhood to define whether a sub-trajectory should be incorporated into an existing cluster or not; it also requires a minimum number of sub-trajectories for a cluster to be formed.
On the number of cells that make up the lattice, as previously mentioned, its value depends on the precision with which the analysis of the trajectories is to be carried out. The fewer cells used, the larger the coverage area of each cell and the less accurate the information or description of the centroids. In this paper, several experiments were performed with sizes ranging from
Table 2 shows the results obtained after the execution of the proposed K-pivot method with the three sets of positions data (Beijing, Guayaquil, and Aracaju). The 16 groups formed by the method are shown together with the percentage of sub-trajectories assigned to each group.
Percentage of Sub-Trajectories Assigned to Each Given Group
The box plot displayed in Figure 9, constructed from the percentages in Table 2, shows that the proposed method adequately distributes the sub-trajectories among all the clusters. It is observed that although groups of different sizes are generated, only one in the case of the Beijing base and two in the case of the Guayaquil base, are much larger than the rest. This is because of the use of the initial lattice where a pivot was located in each square, which allowed a uniform inspection of the entire area of interest.Table 3 shows the quartiles and whisker values of the box plot.
Quartiles and Whisker Values of the Box Plot

Boxplot of the percentages of the sub-trajectories.
Figure 10 shows the clusters obtained by each of the data sets (Guayaquil, Aracaju, and Beijing respectively) with the proposed K-pivot method.

Clusters determined with the proposed K-pivot method.
Validation
The Silhouette index (
75
), considering the Hausdorff distance to compare two sub-trajectories, is used to validate the clustering results. Equation 3 indicates how to calculate the Silhouette index for the
where
Table 4 summarizes the values of the average silhouette indexes for each cluster for the proposed and the benchmark methods. As can be seen, the silhouette indices of the proposed K-pivot method are slightly higher than the obtained K-centroid and Tra-DBScan methods.
Average Silhouette Index for Each Method
Note: The best Silhouette index is in bold.
Given that the silhouette indices obtained by the K-pivot and K-centroid methods do not show significant differences, it was also proposed to analyze, for both methods, the interquartile ranges of the silhouette indices of the sub-trajectories that make up each group once the process was completed.
It is important to note that both methods start with the same lattice. It is also noteworthy that, if the lattice cells were numbered from 1 to 16, a direct correspondence would be observed between the centroids of both methods. That is, for example, the first centroid of the cluster generated by K-pivot would correspond to sub-trajectories of the first cell of the map as well as the first centroid of the cluster generated with K-centroid. This was verified for all cells. On this basis, it was possible to directly compare the silhouette indices of the
Then, the pairwise clusters are compared: the
Table 5 shows the results obtained by applying the K-pivot and K-centroid methods to the Beijing data. It can be seen that 64.97% of the groups generated with the proposed method, K-pivot, comply with the characteristics mentioned for the interquartile range and the quartiles that limit the box of the corresponding diagram. On the other hand, the K-centroid method does the same for the remaining 35.03% of the groups. This shows that the proposed method generates groups with lower dispersion and greater separation between clusters.
Interquartile Range of the First and Third Quartiles of Silhouette
Based on the results reported in Table 4 and the comparison observed in Table 5, we thus find that the incorporation of the pivot improves the quality of the clustering.
Conclusions
The key contribution of the K-pivot clustering technique proposed in the present paper lies precisely in the use of a pivot as a guide for the recalculation of each centroid.
To plot the pivot, the area of highest sub-trajectory concentration of the cluster is taken into account together with the corresponding average direction. The proposed method uses the segmentation strategy defined by Reyes-Zambrano et al. ( 44 ) which allows shorter sub-trajectories with minor direction changes to be used. To establish the position of the initial centroids, a regular lattice was used to ensure its uniform distribution in the area under study.
The proposed method was compared with a variant of the K-means algorithm adapted for the treatment of sub-trajectories called K-centroid, as well as with the Tra-DBScan method. The clusters obtained with the proposed K-pivot method were distributed over the area under study. The quality of the clustering results of the sub-trajectories obtained by the K-pivot method using the silhouette index was satisfactory. Furthermore, the comparison with the Tra-DBScan method reveals the influence of the lattice on the results. The clusters obtained with the proposed K-pivot algorithm are uniformly distributed in the area under study, while those generated by Tra-DBScan are concentrated in specific positions. The quality of the clustering results for the sub-trajectories obtained by means of the silhouette index were satisfactory. In fact, the introduction of the pivot improves the quality of the clustering. In this way, it will be possible to characterize the different sectors of the map that the trajectories cover, identifying possible levels of congestion.
The proposed method can identify a conglomerated trajectory that can be indicative of traffic congestion, even detecting the vehicular flow levels in avenues or main roads, in peak hours mainly, or any other situation such as an accident or any traffic stoppage. The method gives the direction of the traffic and this information is important for decision making and can focus the resulting cluster in an specific area in a road map.
In the future, it is proposed to make adaptations in the way the pivot orientation is defined. This will include other sub-trajectory characteristics that may influence both its direction and angle. It is also intended to evaluate the results of clustering using dynamic clustering algorithms in which it is not necessary to define initial centroids for the identification of patterns.
Footnotes
Author Contributions
The authors confirm contribution to the paper as follows: study conception and design: Gary Reyes, Laura Lanzarini, Waldo Hasperué; data collection: Gary Reyes; analysis and interpretation of results: Gary Reyes, Laura Lanzarini, Waldo Hasperué, Aurelio F. Bariviera; draft manuscript preparation: Gary Reyes, Laura Lanzarini, Waldo Hasperué, Aurelio F. Bariviera. All authors reviewed the results and approved the final version of the manuscript.
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
Data Accessibility Statement
Guayaquil data set is available at https://github.com/gary-reyes-zambrano/Guayaquil-Dataset.git. Beijing data set is available at >https://www.microsoft.com/en-us/research/publication/t-drive-trajectory-data-sample/. Aracaju data set is available at ![]()
