# Trajectory Data Compression Algorithm Based on Motion State Changing

Authors: Shuo Zhang; Jian Zhang; Lin Qi
Journal: Mathematical Problems in Engineering
 (2021)

---

## Abstract

The trajectory information generated by the moving object plays an important role in studying the object movement. In this paper, a trajectory data compression algorithm based on the motion state changing is proposed to reduce trajectory data storage space and increase compression speed, which can accurately show the motion state and trajectory characteristics. This study has certain significance for the exploration of mass traffic data and the planning of traffic network. Combining the angle threshold with the velocity threshold of a moving object, the key data points are found and the redundant information is removed. Subsequently, the compressed trajectory is obtained. The experimental results show that the new algorithm can help to improve compression efficiency. The compressed trajectory has high similarity with the original trajectory in movement tendency.


---

## Body

## 1. Introduction

With the development of economy and technology, mobile devices and global positioning system are popular in various industries [1, 2]. In particular, data collection and storage of trajectory information with the characteristics of time, location, speed, and direction are showing high-speed growth. Currently, how to compress and dispose the GPS data is becoming a hot spot. In 1973, David Douglas and Thomas Peucker presented a classical Douglas–Peucker algorithm to preferentially delete some points by means of information loss in iterative calculations. Afterwards, this algorithm was improved by many scholars. Hershberger John implemented the Douglas–Peucker algorithm for line simplification [3], and Jin et al. studied near-linear time approximation algorithms for curve simplification by reducing the time complexity [4]. In addition, Keogh proposed the Opening Window (OPW) algorithm based on the same algorithm in which the trajectory is simplified by iterative information loss. This algorithm cannot track information of the whole iteration; it is based on the concept of “open window” in which the algorithm “window” contains only a portion of track point iteration. Then, it keeps updating the track information in the “window” until the whole track simplification is completed. This algorithm can be synchronized with online track compression [5]. The sliding window algorithm [6] is similar to the open window algorithm, the main idea of which is to start from the track start, initialize a sliding window size of 1, and gradually expand the window, thereby adding subsequent trajectory points. After connecting the first path point within the window and the last track point, the resulting segment is considered as segment approximation. Sliding window algorithm is used to calculate the approximate vertical line segment with the original track Euclidean distance; if the distance is less than the predetermined distance threshold, then continue to increase the sliding window. This process is repeated until the error is within the window. However, the abovementioned algorithm uses less track information using GPS time information. For this situation, Meratnia proposed a Top-Down Time Ratio algorithm [7]. This algorithm uses synchronous Euclidean distance (SEDm) in place of the vertical distance, which takes into account the time information from GPS track information. Coclite et al. [8] proposed using the road network of semantic information instead of track points to store compressed track objects and performed experimental studies in 2012. Yeh et al. used the oppressed road network link information in conjunction with information of the mobile objects’ time to enter and leave the track [9]. This largely highly compressed the data storage. Threshold algorithm is another type of algorithm proposed by Al-Hussaeni et al. [10]. This algorithm is based on the moving object speed and direction at locus points to predict binding region threshold set at a point that may exist. Location prediction is decided by retaining or removing the points. Threshold algorithm deletes redundant indicator points based on speed and direction, and the algorithm takes into account the state trajectory, but the area to predict the next big point will possibly cause more points to delete. However, it can achieve a high compression ratio and has led to track trends and similar characteristics. Based on the above reasons, this paper constructs new indicators based on speed and angle, namely, the weighted combination of both thresholds to find the key points, and through statistical sampling to find the most appropriate threshold.


## 2. Compression Algorithm Based on Angle Threshold

The data used in this study are the taxi GPS positioning data of a Chinese megacity. The objective of the data compression algorithm is to show the trajectory form of taxi movement with the least GPS data.Suppose there aren taxi tracks. Xi represents i track, and each track has mi dots. A point of each track contains time, position, speed, and direction of rate in the GPS. Xij represents j point of i track, where j=1,⋯,mi, and Xij=tij,xij,yij,vij,θij. Five components of Xij represent time, longitude, latitude, speed, and speed direction in j point of i track.Due to fewer data points collected for each track, the data storage and calculating speed will be greatly affected. Therefore, the track can be compressed to find key points and remove redundant data on the premise that there is no loss of essential feature track [11–14]. In order to reduce the data amount, it is necessary to find the retained or removed data point indicators. From an intuitive point of view, when the velocity of a track point of direction change is large, it indicates that the vehicle is traveling or changing its track due to road change or incidental situation [15]. Thus, this paper first considers the speed direction (angle) as a screening data point indicator.θα is defined as the angle threshold, which is used to eliminate the trajectory points which are less than the angle threshold, and the scope of angle threshold is greater than 5 and less than 20. Δθij,j+1=θij+1−θij represents the absolute value of the change in the direction of the velocity values of two adjacent points in i track. If Δθij,j+1≤θα, Xijis deleted; if Δθij,j+1>θα, Xijis retained.According to this principle, from the first point of a track, successive points will be tested backwards to get a compressed trajectory. In order to reflect the effect of compression, the compression ratio is defined as follows:(1)Yiθα=mi−miHmi,where Yiθα represents the compression rate of i track with angle threshold θα and mi and miH represent, respectively, the number of track points in i track before and after compression [16].Angle thresholdθα is defined, respectively, as 5, 10, 15, and 20 in this paper. In nearly a month, running track (an example of the sample database shown in Table 1) of 2000 taxis in Beijing is verified, indicating that, with an increase in θα, the average compression rate increases.Table 1
Example of the sample database.
Plate numberTimeLongitudeLatitudeSpeedDirection (angle)66914820121130044746116.13439.642019466914820121130001657116.37339.9872518466914820121130001751116.37339.9845416666914820121130001845116.37439.984716466914820121130001940116.37539.976016866914820121130002033116.37539.9744318666914820121130002126116.37439.9672326866914820121130002219116.36539.96760268With the increase in the angle threshold, the change of the average compression rate of 2000 taxis is shown in Figure1. It can be seen from Figure 1 that the average compression rate is more than 45% and the time efficiency is improved greatly. However, since only the information point of view is considered, some points with an important feature of the information have been deleted so that the original motion trajectory trend has changed; for example, the license plate number “669148” taxi track is shown in Figure 2.Figure 1
The trend of the average compression rate with the angle threshold.Figure 2
Trajectory map before and after compression at different angles.In Figure2, with the angle threshold values of 5, 10, 15, and 20, four figures are shown before and after compression of the taxi track; the red trace is the original track and the blue trace is the track after compression. It is obvious that the significant changes in movement trend between points A and B before and after compression have taken place as shown in Figure 2; the main reason is that the locus points between points A and B are all deleted. In order to avoid the deletion of some key data points, the compression ratio is usually reduced. Therefore, we need to add a new threshold to filter the key data points that need to be retained. Thus, the information in the locus points contain the speed at different time periods; in addition, the size of the rate of change reflects whether there is traffic congestion or smooth, and it reveals the trajectory of internal features. If the speed is the only indicator, the situation with the angle threshold control of key points is bound to arise, which can get a higher compression ratio [17]. But it will lose some points that reflected track trends, and the characteristics of the track cannot be fully demonstrated by the rest of the points. For these reasons, this paper, used the two indicators angle and speed as the key points of track [18–20].


## 3. Compression Algorithm Based on Angle and Speed Threshold

Speed threshold is defined asvα, which is used to eliminate the trajectory points which are less than the speed threshold, and the scope of the speed threshold is greater than 5 and less than 20. Δvij,j+1=vij+1−vij represents the absolute value of the change in the speed of the velocity values of two adjacent points in i track. These points that meet the limit of angle threshold and speed threshold are deleted, namely, if Δθij,j+1≤θα and Δvij,j+1≤vα, Xijis deleted, or else, Xij is retained.According to this principle, from the first point of a track, successive points will be tested backwards to get a compressed trajectory. The track is still referred to beXiH in the case not to cause confusion. Simultaneously, the compression ratio is defined as follows:(2)Yiθα,vα=mi−miHmi,where mi is as defined above and miH is the number of compressed track points in the angle and speed threshold control.Angle thresholdθα is defined, respectively, as 5, 10, 15, and 20, and the speed threshold vαis defined, respectively, as 5, 10, 15, 20, 25, and 30 in this paper. Thus, 30 combinations are obtained.As shown in Figure3, track trends of A and B points before and after compression are well preserved in this method. In Figure 3, tracks are shown in the last small picture with grid before and after compression when θα = 25 and vα = 30. In addition, two encircled points, respectively, in Figure 3 are points A and B in Figure 2. It is very intuitive that motion trends of point A and point B were retained well even in the larger threshold, but the compression ratio of this algorithm is lower. The average compression ratio of 2000 taxi track trends with the angle and speed threshold values at the same time is shown in Figure 4. Thus, the highest value of compression ratio is about 50% and the lowest value is only about 20%. We have paid more attention to keeping contrail features and being stringent to take data points so that a few points meet the speed and angle threshold. Besides, it leads to a situation that the similarity of the track shape is higher, but the compression rate is lower. When the angle and velocity threshold values change, the compression ratio also changes in size as shown in Figure 4.Figure 3
Trajectory map before and after compression at different angles and speeds.Figure 4
The change of angle threshold and velocity threshold leads to the change trend of compression ratio.


## 4. Compression Algorithm of Trajectory Data Based on Motion State Change

Assuming a new index, the weighted threshold value for velocity and angle, so as to obtain higher compression ratio and retain important information after compression [21], the index is marked as θvα. Making Δθvij,j+1=α1Δθij,j+1+α2Δvij,j+1, whereΔθij,j+1 and α2 are the weights of Δθij,j+1 and Δvij.j+1, respectively. If Δθvij,j+1≤θvα, Xij is deleted; else, Xijis retained.Using the mathematical model established above, each data point of the vehicle trajectory data is screened in turn, and the key data points left by the screening are used to form the compressed vehicle trajectory. Without a disordered case, mark the compressed trajectory asXiH, and the compression ratio is defined as Yiθvα=mi−miH/mi, but mi as primary. Under the control of the weighted threshold value for velocity and angle, miHis the number of trajectory points compressed [22].Reduced trajectory was not only considering efficiency, but it was also guaranteeing the compressed trajectory as well as the original trajectory. In order to reflect the similarity of the two trajectories before and after compression, the diversity of the two trajectories is defined.Di represents the absolute difference of i track before and after compression. Owing to the concern about kinetic trend changes before and after compression [23], area of the shadow that the compression trajectory and the original trajectory are surrounded by was not too large, as shown in Figure 5.Figure 5
The area of the shadow that the compression trajectory and the original trajectory are surrounded by.In Figure5, the red line represents the point of original trajectory data and the blue line represents the point of compressed trajectory data. If key points are selected properly, the shaded area would be as small as possible. Based on the above considerations, define(3)Di=∑j−1mi−1yj+yj+1xj+1−xj−∑k−1miH−1ykH+yk+1Hxk+1H−xkH=Si−SiH,where Si is the area of the original trajectory surrounding the horizontal axis and SiH is the area of the compressed trajectory surrounding the horizontal axis.Because of the different lengths of the original trajectory, the difference between the two tracks is called relative diversity, to be calledDi′=Di/Si. Taking θvα = 10, 15, 20, 25, and 30 and (α1,α2) = (0.1, 0.9), (0.2, 0.8), (0.3, 0.7), (0.4, 0.6), …, (0.9, 0.1) as weights, the experiments of 2000 trajectories were run. According to various values, the average trajectory compression ratio was calculated and the average relative diversity was reckoned. The group that had a high average compression rate and a low average relative diversity as final thresholds and last weights was selected. Test results are shown in Table 2. In order to conveniently determine the threshold value and weights, choose by the size of P=1 − the average compression ratio + (1 − the average relative diversity). As is shown in Table 1, when θvα=30, P-values for different situations are maximum. So 30 and 0.6, 0.4 were determined as threshold value and weights. At the moment, the average compression ratio was greater than 71%, the average relative diversity was only 10%, and the similarity of the original trajectory and the compressed trajectory was approximately 90%.Table 2
Average compression ratio and average relative diversity of different threshold values and weights.
Threshold valueWeight 1Weight 2The average compression ratioThe average relative diversity1 − the average relative diversityP = 1 −  the average compression ratio + (1 −  the average relative diversity)100.10.90.43980.240870420.759129581.1989295830.20.80.406015040.000378940.999621061.4056360940.30.70.398496240.000400070.999599931.3980961670.40.60.390977440.000401750.999598251.3905756970.50.50.413533840.000401710.999598291.4131321240.60.40.424812030.000344750.999655251.4244672790.70.30.330827070.000318650.999681351.3305084190.80.20.49624060.091095960.908904041.4051446410.90.10.49624060.095148990.904851011.401091612150.10.90.50.281096670.718903331.2189033310.20.80.488721810.000766050.999233951.4879557510.30.70.51127820.00046190.99953811.5108162940.40.60.50375940.00046160.999538411.5032978040.50.50.522556390.000693790.999306211.5218625990.60.40.548872180.094129480.905870521.4547426990.70.30.394736840.000401750.999598251.394335090.80.20.593984960.095278420.904721581.498706540.90.10.593984960.095267710.904732291.498717254200.10.90.59770.284651530.715348471.3130484740.20.80.578947370.244254660.755745341.334692710.30.70.545112780.000765750.999234251.5443470350.40.60.578947370.094435270.905564731.4845120940.50.50.601503760.094130020.905869981.5073737360.60.40.620300750.094186880.905813121.5261138720.70.30.49624060.000461690.999538311.495778910.80.20.642857140.095327090.904672911.5475300490.90.10.642857140.095327860.904672141.547529287250.10.90.64290.323579060.676420941.3193209390.20.80.627819550.290110790.709889211.3377087620.30.70.624060150.097596240.902403761.5264639140.40.60.646616540.097604080.902395921.5490124610.50.50.672932330.098543590.901456411.5743887420.60.40.672932330.096350910.903649091.5765814190.70.30.526315790.000693790.999306211.5256219970.80.20.684210530.097809540.902190461.5864009830.90.10.684210530.10198320.89801681.582227325300.10.90.74060.572476570.427523431.168123430.20.80.703007520.385685710.614314291.3173218110.30.70.714285710.34005060.65994941.3742351140.40.60.695488720.098539230.901460771.5969494880.50.50.691729320.099636090.900363911.5920932310.60.40.718045110.102386040.897613961.6156590760.70.30.586466170.094130120.905869881.4923360420.80.20.699248120.102093190.897906811.5971549260.90.10.699248120.102093110.897906891.597155012


## 5. Conclusions and Discussion

Exploring the law of vehicle trajectory data can uncover some important road network information, which can provide effective decisions and suggestions for reducing road congestion and planning of traffic routes. To explore the value of object trajectory information, we study a vehicle trajectory data compression algorithm based on the change of motion state. The advantage of the algorithm is that the vehicle trajectory data compression rate is high, and the vehicle motion state and trajectory characteristics can be displayed as accurately as possible. In the research process of the algorithm, we use the GPS data of taxi track to do a lot of experiments to explore the impact of speed threshold and angle threshold on the track data compression rate. According to the experimental results, we propose a threshold combination algorithm, which improves the data compression rate by changing the threshold parameters and makes the compressed data clearly show the characteristics of vehicle trajectory. Reference values are as follows:(1)
Angle threshold is defined, respectively, as 5, 10, 15, and 20 in this paper. In nearly a month, running track of 2000 taxis in Beijing is verified, when the average compression rate is more than 45%. However, some points with an important feature of the information have been deleted so that the original motion trajectory trend has changed. Obviously, it is unscientific to only use the angle threshold to screen out the key data points in the vehicle trajectory; therefore, we need to add a new threshold to screen out the key data points that need to be retained. Thus, the information about the locus points contains the speed at different times; in addition, the size of the rate of change reflects whether there is traffic congestion or smooth, and it reveals the trajectory of internal features. If the speed is the only indicator, the situation with the angle threshold control of key points is bound to arise, which can get a higher compression ratio. But it will lose some points that reflected track trends, so that the characteristics of the track cannot be fully demonstrated by the rest of the points.(2)
Angle threshold is defined, respectively, as 5, 10, 15, and 20, and speed threshold is defined, respectively, as 5, 10, 15, 20, and 25; the highest value of compression ratio is about 50%, and the lowest value is only about 20%. We have paid more attention to keeping contrail features and being stringent to take data points so that a few points meet the speed and angle threshold. Besides, it leads to a situation that the similarity of the track shape is higher, but the compression rate is lower.(3)
Using speed threshold and angle threshold to set a new index so as to obtain higher compression ratio and retain important information after compression, the index setting and parameter selection can be obtained through a large number of experiments. Angle threshold and velocity threshold are controlled by parameters so that reduced trajectory was not only considering efficiency but also guaranteeing the compressed trajectory as well as the original trajectory. Finally, the vehicle trajectories before and after compression are presented and similarity analysis is carried out.



---

*Source: 6647074-2021-02-28.xml*