# A Direction-Preserved Vessel Trajectory Compression Algorithm Based on Open Window

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

- A direction-preserved vessel trajectory compression algorithm based on Open Window is proposed for the first time. Open Window algorithms can handle both offline data and compress vessel trajectories online. The method directly calculates the direction difference between the original trajectory segments and the potentially compressed segments instead of judging the direction change in adjacent trajectory segments through the COG while the compression is based on distance thresholds, which avoids the problem of the inaccurate retention of direction changes due to the delayed and erroneous COGs. The vessel trajectory compressed by the method in this paper can effectively retain the direction change feature points while ensuring the position error. The results can be applied to ship traffic pattern mining algorithms that rely heavily on the direction information of vessel trajectories, such as clustering, anomaly detection, classification, etc.
- Certain deficiencies are improved when using the direction-preserved compression method. There are a large number of low-speed redundant points in vessel trajectories, such as at anchor, moorings, and sailing with low speed. The direction-preserved compression method is sensitive to direction change, while the low-speed points may undergo huge direction changes at a particularly close distance due to the drift of the position. When applying the direction-preserved compression method, the data in this part cannot be compressed. In this paper, the radial distance method is applied to process the ship trajectory before the direction-preserved compression method, which can sufficiently eliminate the low-speed redundant points of the vessel’s trajectory.
- Compared with the position-preserving compression algorithm, the method proposed in the article has been greatly improved in terms of compression time. The position-preserving compression method needs to recalculate the distance between the original vessel trajectory points and the potential trajectory segments when the potential trajectory segments are changed and the amount of calculation is larger. The direction-preserved compression method, on the other hand, only requires a one-time calculation of the original segment direction. Moreover, when the potential trajectory segment changes, it only needs to compare the direction between the original segments and the potential trajectory, and it does not need to recompute. The method proposed in the article greatly decreases the running time of vessel trajectory compression. This is especially evident in the online compression process, which is when the real-time requirements of the algorithm are high and the advantages of the article’s method are more obvious.

## 2. Related Work

## 3. Methodology

#### 3.1. Problem Definition

- Conversion of geographical coordinates to the Mercator projection.
- Direction and Distance calculation.
- Trajectory slices according to the report interval.
- Trajectory anomaly processing.
- Low-speed trajectory with Radial Distance.
- Vessel trajectory compression by direction and speed thresholds based on Open Window

#### 3.2. Geographical Coordinate Conversion and Direction and Distance Calculation

#### 3.3. Ship Trajectory Pre-Processing

Algorithm 1: Trajectory slice algorithm |

#### 3.4. Direction-Preserved Vessel Trajectory Compression Algorithm

Algorithm 2: Radial Distance algorithm |

Algorithm 3: Speed error judgment algorithm |

Algorithm 4: Direction-Preserved Vessel Trajectory Compression algorithm |

## 4. Results Analysis and Discussion

#### 4.1. Compression Rate

#### 4.2. Running Time

#### 4.3. Position Error and Speed Error

#### 4.4. Visualization Analysis of the AIS Trajectory Simplification Performance

## 5. Conclusions

- The compression rate increases significantly when we increase the tolerance from 0 slightly, and it increases slowly when the tolerance is above a certain value. Compared with the DPTS algorithm (with the same tolerance), the compression rate of the port water datasets increased by 21% to 31%, and coastal water datasets increased by 10% to 15%.
- The compression time becomes longer as the direction threshold increases. The running time of the proposed algorithm was significantly improved compared with the DP algorithm, especially in the port water datasets. Furthermore, the running time of the DP method was 6 to 8 times of the proposed algorithm with port water datasets. For the coastal water datasets, the running time was 3 to 4 times.
- The algorithm based on distance thresholds (DPs) performed better with respect to position error. When the compression rate was close to 95%, the proposed method’s average position error changed quickly; as such, we recommend that the compression ratio not exceed 95%. The recommended threshold for port waters is 0.3 radian, and the threshold for coastal waters is 0.1 radian. Because the proposed algorithm incorporates a velocity threshold, it outperforms the other two algorithms in the retention of velocity information.

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## Abbreviations

AIS | Automatic Identification System |

COG | Course over ground |

DPTS | Direction-Preserving Trajectory Simplification |

NMEA | National Marine Electronics Association |

SOG | Speed over ground |

SOLAS | International Convention for Safety of Life at Sea |

TS | Trajectory simplification |

VHF | Very high frequency |

## References

- IMO. SOLAS: Consolidated Text of the International Convention for the Safety of Life at Sea, 1974, and its Protocol of 1988; IMO: London, UK, 2014. [Google Scholar]
- Series, M. Technical Characteristics for an Automatic Identification System Using Time-Division Multiple Access in the VHF Maritime Mobile Band; Recommendation ITU: Geneva, Switzerland, 2014; pp. 1371–1375. [Google Scholar]
- Di Ciaccio, F.; Menegazzo, P.; Troisi, S. Optimization of the Maritime Signaling System in the Lagoon of Venice. Sensors
**2019**, 19, 1216. [Google Scholar] [CrossRef] - Huang, C.; Qi, X.; Zheng, J.; Zhu, R.; Shen, J. A maritime traffic route extraction method based on density-based spatial clustering of applications with noise for multi-dimensional data. Ocean Eng.
**2023**, 268, 113036. [Google Scholar] [CrossRef] - Liu, C.; Zhang, S.; Cao, L.; Lin, B. The Identification of Ship Trajectories Using Multi-Attribute Compression and Similarity Metrics. J. Mar. Sci. Eng.
**2023**, 11, 2005. [Google Scholar] [CrossRef] - Xiao, Z.; Fu, X.; Zhang, L.; Goh, R.S.M. Traffic Pattern Mining and Forecasting Technologies in Maritime Traffic Service Networks: A Comprehensive Survey. IEEE Trans. Intell. Transp. Syst.
**2020**, 21, 1796–1825. [Google Scholar] [CrossRef] - Liu, Z.; Gao, H.; Zhang, M.; Yan, R.; Liu, J. A data mining method to extract traffic network for maritime transport management. Ocean Coast. Manag.
**2023**, 239, 106622. [Google Scholar] [CrossRef] - Jiang, D.; Shi, G.; Li, N.; Ma, L.; Li, W.; Shi, J. TRFM-LS: Transformer-Based Deep Learning Method for Vessel Trajectory Prediction. J. Mar. Sci. Eng.
**2023**, 11, 880. [Google Scholar] [CrossRef] - Xiao, Z.; Ponnambalam, L.; Fu, X.; Zhang, W. Maritime Traffic Probabilistic Forecasting Based on Vessels’ Waterway Patterns and Motion Behaviors. IEEE Trans. Intell. Transp. Syst.
**2017**, 18, 3122–3134. [Google Scholar] [CrossRef] - Zhen, R.; Jin, Y.; Hu, Q.; Shao, Z.; Nikitakos, N. Maritime Anomaly Detection within Coastal Waters Based on Vessel Trajectory Clustering and Naïve Bayes Classifier. J. Navig.
**2017**, 70, 648–670. [Google Scholar] [CrossRef] - Shatkay, H. Approximate Queries and Representations for Large Data Sequences. In Proceedings of the Twelfth International Conference on Data Engineering, New Orleans, LA, USA, 26 February–1 March 1995. [Google Scholar]
- Douglas, D.H. Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. Cartogr. Int. J. Geogr. Inf. Geovisualization
**1973**, 10, 112–122. [Google Scholar] [CrossRef] - Shukai, Z.; Zhengjiang, L.; Xianku, Z.; Guoyou, S.; Yao, C.; University, D.M. A method for AIS track data compression based on Douglas-Peucker algorithm. J. Harbin Eng. Univ.
**2015**, 36, 595–599. [Google Scholar] - Zhao, L.; Shi, G.; Yang, J. Ship trajectories pre-processing based on AIS data. J. Navig.
**2018**, 71, 1210–1230. [Google Scholar] [CrossRef] - Zhang, S.K.; Liu, Z.J.; Cai, Y.; Wu, Z.L.; Shi, G.Y. AIS trajectories simplification and threshold determination. J. Navig.
**2016**, 69, 729–744. [Google Scholar] [CrossRef] - Wei, Z.; Xie, X.; Zhang, X. AIS trajectory simplification algorithm considering ship behaviours. Ocean Eng.
**2020**, 216, 108086. [Google Scholar] [CrossRef] - Cui, C.; Dong, Z. Ship Space-Time AIS Trajectory Data Compression Method. In Proceedings of the 2022 7th International Conference on Big Data Analytics (ICBDA), Tokyo, Japan, 16–18 March 2022; pp. 40–44. [Google Scholar]
- Sánchez-Heres, L.F. Simplification and event identification for AIS trajectories: The equivalent passage plan method. J. Navig.
**2019**, 72, 307–320. [Google Scholar] [CrossRef] - Vitter, J.S. Random sampling with a reservoir. ACM Trans. Math. Softw. (TOMS)
**1985**, 11, 37–57. [Google Scholar] [CrossRef] - Keogh, E.; Chu, S.; Hart, D.; Pazzani, M. An online algorithm for segmenting time series. In Proceedings of the 2001 IEEE International Conference on Data Mining, San Jose, CA, USA, 29 November–2 December 2001; pp. 289–296. [Google Scholar]
- Meratnia, N.; de By, R.A. Spatiotemporal compression techniques for moving point objects. In Proceedings of the Advances in Database Technology-EDBT 2004: 9th International Conference on Extending Database Technology, Heraklion, Greece, 14–18 March 2004; pp. 765–782. [Google Scholar]
- Miao, G.; Guo-you, S.; Wei-feng, L. Online compression algorithm of AIS trajectory data based on improved sliding window. Jiaotong Yunshu Gongcheng Xuebao/J. Traffic Transp. Eng.
**2018**, 18, 218–227. [Google Scholar] - Sun, S.; Chen, Y.; Piao, Z.; Zhang, J. Vessel AIS trajectory online compression based on scan-pick-move algorithm added sliding window. IEEE Access
**2020**, 8, 109350–109359. [Google Scholar] [CrossRef] - Zhu, F.; Ma, Z. Ship trajectory online compression algorithm considering handling patterns. IEEE Access
**2021**, 9, 70182–70191. [Google Scholar] [CrossRef] - Cao, W.; Li, Y. DOTS: An online and near-optimal trajectory simplification algorithm. J. Syst. Softw.
**2017**, 126, 34–44. [Google Scholar] [CrossRef] - Zhang, Y.; Shi, G.; Li, S. Compression algorithm of ship trajectory based on online directed acyclic graph. Jiaotong Yunshu Gongcheng Xuebao/J. Traffic Transp. Eng.
**2020**, 20, 227–236. [Google Scholar] - Long, C.; Wong, R.C.W.; Jagadish, H. Direction-preserving trajectory simplification. Proc. VLDB Endow.
**2013**, 6, 949–960. [Google Scholar] [CrossRef] - Deng, Z.; Han, W.; Wang, L.; Ranjan, R.; Zomaya, A.Y.; Jie, W. An efficient online direction-preserving compression approach for trajectory streaming data. Future Gener. Comput. Syst.
**2017**, 68, 150–162. [Google Scholar] [CrossRef] - Osborne, P. The Mercator Projections; Zenodo: Geneva, Switzerland, 2016. [Google Scholar] [CrossRef]

**Figure 2.**Examples of trajectory with a low-speed point. The gray box in the figure includes three trajectory points that are at small distances from each other, but the difference in direction of the trajectory segments is large.

**Figure 3.**Illustration of the speed error between the original speed and speed from interpolation. The black dots represent the ship’s speeds at the corresponding moments, and the red line represents the linear change of the speed from the starting point to the end point, after compress the trajectory, we can find the ship’s speeds at ${t}_{i}$ through the linear interpolation(the white circle on the red line). The speed error at ${t}_{i}$ is ${v}_{i}^{\prime}-{v}_{i}$.

**Figure 5.**Statistical results of the speed distribution in port waters. (

**a**) Frequency distribution chart of the different speeds. (

**b**) Cumulative frequency distribution chart of the different speeds.

**Figure 6.**Statistical results of the speed distribution in coastal waters. (

**a**) Frequency distribution chart of the different speeds. (

**b**) Cumulative frequency distribution chart of the different speeds.

**Figure 7.**Theoretical schematic of the radial distance method to deal with the low-speed AIS trajectory points. In (

**a**), the distance from ${p}_{1}$, ${p}_{2}$ to ${p}_{0}$ are less than ${\u03f5}_{\rho}$, so these two points are deleted. In (

**b**), ${p}_{3}$ is the key point, and no points were deleted. In (

**c**), ${p}_{4}$ is the key point, and the distance from ${p}_{5}$ is less than ${\u03f5}_{\rho}$, so ${p}_{5}$ is deleted. In (

**d**), after the radial distance method, the remaining points were ${p}_{0},{p}_{3},{p}_{4},{p}_{6}$.

**Figure 8.**Theoretical schematic of the Open Window method to compress the AIS trajectory based on directional threshold.

**Figure 9.**The area where the experimental data are located. (

**a**) The coastal waters in eastern Zhejiang. (

**b**) The port area at Yingkou Ports.

**Figure 10.**Comparison of the compression rate between the proposed method (DPTSM) and the DPTS method with the same tolerance. (

**a**) Comparison of the rate in port waters. (

**b**) Comparison of the rate in coast waters.

**Figure 11.**Comparison of the running time between the proposed method (DPTSM) and the DPTS method with the same tolerance. (

**a**) Comparison of the running time in port waters. (

**b**) Comparison of the running time in coast waters.

**Figure 12.**Comparison of the running time between the proposed method (DPTSM), the DPTS method, and the DP method with the same compression rate. (

**a**) Comparison of the running time in port waters. (

**b**) Comparison of the running time in coast waters.

**Figure 13.**Comparison of the running time between the proposed method (DPTSM) and the DP method with the same compression rate (95%) for different data sizes. (

**a**) Comparison of the running time in port waters. (

**b**) Comparison of the running time in coast waters.

**Figure 14.**Comparison of the average position error between the proposed method (DPTSM), the DPTS method, and the DP method with the same compression rate. (

**a**) Comparison of the average position error in port waters. (

**b**) Comparison of the average position error in coast waters.

**Figure 15.**Comparison of the max position error between the proposed method (DPTSM), the DPTS method, and the DP method with the same compression rate. (

**a**) Comparison of the max position error in port waters. (

**b**) Comparison of the max position error in coast waters.

**Figure 16.**Comparison of the average speed error between the proposed method (DPTSM), the DPTS method, and the DP method with the same compression rate. (

**a**) Comparison of the average speed error in port waters. (

**b**) Comparison of the average speed error in coast waters.

**Figure 17.**Comparison of the max speed error between the proposed method (DPTSM), the DPTS method, and the DP method with the same compression rate. (

**a**) Comparison of the max speed error in port waters. (

**b**) Comparison of the max speed error in coast waters.

**Figure 18.**Visual analysis of the port water datasets. (

**a**) is AIS trajectory after compression (

**b**) is AIS trajectory before compression.

**Figure 19.**Visual analysis of the coastal water datasets. (

**a**) is AIS trajectory after compression (

**b**) is AIS trajectory before compression.

Ship Dynamic Conditions | Nominal Reporting Interval |
---|---|

Ship at anchor or moored and not moving faster than 3 knots | 3 min |

Ship at anchor or moored and moving faster than 3 knots | 10 s |

Ship 0–14 knots | 10 s |

Ship 0–14 knots and changing course | 3 1/3 s |

Ship 14–23 knots | 6 s |

Ship 14–23 knots and changing course | 2 s |

Ship > 23 knots | 2 s |

Ship > 23 knots and changing course | 2 s |

# of Ships | Total # of Positions | Average # of Positions Per Trajectory | The Range of Time Periods | |
---|---|---|---|---|

Port waters | 274 | 1,154,259 | 4212.624 | 1–3 June 2020 |

Coastal waters | 759 | 1,175,585 | 1548.86 | 1 May 2021 |

Tolerance | Port Water Datasets | Coastal Water Datasets | ||
---|---|---|---|---|

Proposed (%) | DPTS (%) | Proposed (%) | DPTS (%) | |

0.01 | 74.9624 | 43.6223 | 58.3782 | 43.7457 |

0.02 | 80.862 | 49.8946 | 74.2668 | 59.7033 |

0.03 | 84.3227 | 53.7386 | 82.6386 | 68.1655 |

0.04 | 86.6007 | 56.3758 | 87.4004 | 73.0338 |

0.05 | 88.144 | 58.2332 | 90.2434 | 75.9777 |

0.06 | 89.2624 | 59.6631 | 92.0444 | 77.8844 |

0.07 | 90.1543 | 60.9131 | 93.2495 | 79.1873 |

0.08 | 90.8524 | 61.8728 | 94.1027 | 80.1729 |

0.09 | 91.4385 | 62.7361 | 94.7348 | 80.9376 |

0.1 | 91.9387 | 63.5255 | 95.201 | 81.4949 |

0.2 | 94.5103 | 68.5503 | 97.1415 | 84.5426 |

0.3 | 95.512 | 71.4195 | 97.6818 | 86.09 |

0.4 | 96.0154 | 73.5526 | 97.9239 | 87.0783 |

0.5 | 96.328 | 75.1678 | 98.0795 | 88.0374 |

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Ma, L.; Shi, G.; Li, W.; Jiang, D.
A Direction-Preserved Vessel Trajectory Compression Algorithm Based on Open Window. *J. Mar. Sci. Eng.* **2023**, *11*, 2362.
https://doi.org/10.3390/jmse11122362

**AMA Style**

Ma L, Shi G, Li W, Jiang D.
A Direction-Preserved Vessel Trajectory Compression Algorithm Based on Open Window. *Journal of Marine Science and Engineering*. 2023; 11(12):2362.
https://doi.org/10.3390/jmse11122362

**Chicago/Turabian Style**

Ma, Lin, Guoyou Shi, Weifeng Li, and Dapeng Jiang.
2023. "A Direction-Preserved Vessel Trajectory Compression Algorithm Based on Open Window" *Journal of Marine Science and Engineering* 11, no. 12: 2362.
https://doi.org/10.3390/jmse11122362