# Travel Time Prediction on Long-Distance Road Segments in Thailand
## 3 Materials and Methods
### Data Preparation  
We mainly used GPS data together with road data. The GPS dataset was the GPS tracking data of trucks in Thailand. The dataset collected included the vehicle location and timestamp at every minute from the GPS device, shown in Figure 2. Our work considered data from 2019 because the traffic patterns in that year were not disrupted by the COVID-19 virus. Using the data from trucks, our study focused on the analytics of long-distance roads, and the pre-analysis of these data indicated that many truck GPS data concerned long roads between cities. In addition, the road data for Thailand were prepared from OpenStreetMap [29]. As there were many roads in the road network data, we chose roads that had a high occurrence of truck GPS data. Highways 1, 2, 4, 7, 9, 32, 35, 41, 304, and 331 were included, and they are shown on the map in Figure 3. Since there were no trucks driving along the entirety of the road lines, some long-distance road segments that had a high number of trucks passing through were selected. For example, we chose 332 km of highway number 1, 232 km of highway number 2, and 219 km of highway number 4, which are shown in Tables 1 and 2 under the columns named Distance (km). Next, we used the locations of each truck in the GPS dataset to map them to the road segments and selected only trucks that passed through the beginning point and the end point of each road segment. In this case, there were about a hundred million GPS data entries. Since the timestamp of each truck was found at the beginning point and the end point of a road segment, we were able to calculate the travel time of each road segment, as shown in Table 1. In addition, the stopping times, which were calculated from a duration of longer than 20 min in the same location, were excluded. Table 1 shows example data for highway number 1, where each entry is the average travel time from every beginning hour. Thus, this dataset can be viewed as time-series data with an hourly sampling rate. For example, the first data row of Table 1 means that trucks entering the starting point of the road segment highway number 1 during 00:00 and 00:59 took an average travel time of 18,421.14 s (about 5 h and 7 min) to the end point of that road segment. To better understand the dataset, the average hourly travel time of trucks on highway number 1 in 2019 is plotted in Figure 4. In addition, the processed data are summarized in Table 2. There were 81,068 unique trucks with 2,010,270 trips and an average travel time of 203.04 min. Figure 2: Examples of GPS data of vehicles with data fields that include a date time (timestamp), a masked identifier for each vehicle (vid), a latitude (lat), and a longitude (lon). \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{**Road Segment**} & **Distance** & **Date** & **Hour** & **Travel Time** \\  & **(km)** & **Date** & **Duration** & **(Seconds)** \\ \hline Highway No. 1 & 332 & 2019-02-14 & 00:00–00:59 & 18,421.14 \\ Highway No. 1 & 332 & 2019-02-14 & 01:00–01:59 & 16,412.50 \\ Highway No. 1 & 332 & 2019-02-14 & 02:00–02:59 & 15,809.55 \\ Highway No. 1 & 332 & 2019-02-14 & 03:00–03:59 & 15,206.60 \\ Highway No. 1 & 332 & 2019-02-14 & 04:00–04:59 & 16,552.00 \\ Highway No. 1 & 332 & 2019-02-14 & 05:00–05:59 & 17,110.75 \\ Highway No. 1 & 332 & 2019-02-14 & 06:00–06:59 & 14,216.83 \\ Highway No. 1 & 332 & 2019-02-14 & 07:00–07:59 & 15,873.13 \\ Highway No. 1 & 332 & 2019-02-14 & 08:00–08:59 & 15,494.25 \\ Highway No. 1 & 332 & 2019-02-14 & 09:00–09:59 & 20,464.50 \\ Highway No. 1 & 332 & 2019-02-14 & 10:00–10:59 & 14,278.20 \\ Highway No. 1 & 332 & 2019-02-14 & 11:00–11:59 & 16,780.00 \\ Highway No. 1 & 332 & 2019-02-14 & 12:00–12:59 & 14,343.60 \\ \(\dots\) & \(\dots\) & \(\dots\) & \(\dots\) & \(\dots\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Average travel time in seconds on a road at every hour of each day in 2019. It is noted that the date format is YYYY-MM-DD where YYYY is a year, MM is a month, and DD is a day.