# Lane-Level Road Map Construction considering Vehicle Lane-Changing Behavior

Authors: Liang Fan; Jinfen Zhang; Chengpeng Wan; Zhongliang Fu; Shiwei Shao
Journal: Journal of Advanced Transportation
 (2022)

---

## Abstract

In recent years, the construction of lane-level road maps has received extensive attention from industry and academia. It has been widely studied because this kind of map provides the foundation for much research, such as high-precision navigation, driving behavior analysis, and traffic analysis. Trajectory-based crowd-mapping is an emerging approach to lane-level map construction. However, the major problem is that existing methods neglect modeling the trajectory distribution in the longitudinal direction of the road, which significantly impacts precision. Thus, this article proposes a two-stage method based on vehicle lane-changing behavior to model the road’s lateral and longitudinal trajectory distributions simultaneously. In the first stage, lane-changing behaviors are extracted from vehicle trajectories. In the second stage, the lane extraction model is established using the weighted constrained Gaussian mixture model and hidden Markov model to estimate lane parameters (e.g., lane counts and lane centerline) on each road cross section. Then accurate and continuous lane centerlines can be constructed accordingly. The proposed method is verified using vehicle trajectory data collected from the crowdsourced platform named Mapillary. The results show that the proposed method can construct lane-level road information satisfactorily.


---

## Body

## 1. Introduction

Lane-level road maps are the core of automatic driverless systems and intelligent assisted driving systems. It can be used for autonomous vehicle navigation and online driver guidance. Besides, such a map can also be important for lane-based traffic analysis. The analysis of the traffic flow will be done more accurately if it is based on a lane-level map that is fully compatible with the input trajectory data. Currently, lane-level road maps are usually acquired from high-resolution remote sensing images, vehicle-mounted laser point clouds, or differential GPS trajectories with an accuracy of about 0.5–4 m [1]. These manual and semimanual approaches are time-consuming and labor-intensive.Crowdsourcing is a low-cost and efficient way to extract useful road information from data acquired by crowd participants or volunteers. The crowdsourced method has been successfully applied in road map construction, which collects road data by crowding vehicles [2–4]. The advantage of crowdsourced technology has led to a relatively limited number of scholarly papers on lane-level map construction based on crowdsourced trajectories. However, these efforts mainly model the trajectory distribution on road cross sections and do not model the trajectory distribution in the longitudinal direction of the road. It can cause the lane counts on a road to not be constant throughout a segment of the road, while road designers usually maintain the road width constant throughout the segment.This paper proposes a strategy to model the road longitudinal trajectory distribution by considering vehicle lane-changing behavior. The method is based on the observation that the probability of a vehicle changing lanes increases on road sections where the number of lanes changes. Thus, the lane-changing behaviors of vehicles are first identified from their trajectories. Then, we use the weighted constrained Gaussian mixture model (WCGMM) and the hidden Markov model (HMM) to establish the relationship between the vehicle lane-changing behavior and the number of lanes on the adjacent road cross sections. At last, each road segment’s lane counts and lane centerlines are extracted. In summary, the contributions of this paper are the following:(1)
We propose a vehicle lane-changing behavior extraction method based on the clustering of trajectory points.(2)
We propose a lane-level road map construction method based on the simultaneous modeling of the trajectory distribution in a road’s lateral and longitudinal directions.The rest of this article is structured as follows: Section2 gives an overview of works related to this article. Section 3 describes the lane-changing behavior recognition method and the lane centerline extraction approach based on lane-changing behavior. Experiments and results are discussed in Section 4, followed by conclusions and future work in Section 5.


## 2. Related Work

Crowdsourced vehicle trajectory data is a low-cost, real-time data source that potentially contains rich road information. Thus, many scholars have studied building a navigation map using crowdsourced vehicle trajectories [5–8]. With the rise of autonomous driving technology, high-definition navigation maps have become one of the critical capabilities for autonomous driving. It can provide vehicles with more reliable environmental perception capabilities. Compared with traditional navigation maps, high-definition maps for autonomous driving require more real-time and accurate lane information. Constructing lane-level road maps using crowdsourced vehicle trajectories has also become a new research hotspot.Generally, the lane-level road map construction method based on crowdsourced vehicle trajectories usually includes three steps. First, the noise of raw trajectories is filtered. For example, previous studies have used a Kalman filter and a particle filter algorithm [9] or kernel density methods [10] for trajectory data preprocessing. Second, the lane counts of the segment are estimated. In previous studies, Edelkamp and Schrödl [11] proposed a K-means clustering method to extract lane counts from massive differential GNSS trajectories to construct and update urban road digital maps. Uduwaragoda et al. [12] used nonparametric Kernel Density Estimation (KDE) to estimate the number and location of the lane centerlines. Chen and Krumm used vehicle trajectories recorded from standard GPS devices to construct lane-based, routable digital maps [13]. They used perpendicular lines at certain distances relative to the road’s centerline for one-dimensional classification of the trajectories. Then, prior knowledge and the constrained Gaussian mixture model (CGMM) are used to get better classification results. Tang et al. [14] proposed a naive Bayesian classifier to extract the number and the rules of traffic lanes. In addition, an optimized CGMM was proposed to mine the traffic lanes' numbers and locations [15]. Furthermore, a fuzzy-set-based algorithm is proposed to construct the lane geometry near road intersections using traffic rules [16]. Roeth et al. [17] proposed a method based on elementary building blocks that guarantees applicable lane models and used a reversible jump Markov chain Monte Carlo method to explore the model parameters. Third, these lane models of road segments are connected into lanes. Gong et al. proposed a region-growing cluster algorithm with distance and orientation constraints to construct lane-level roads [18]. Arman and Tampère [19, 20] first identify road nodes and divide the network into segments. Then they construct lanes for each segment and connect these lanes. Zheng et al. [21] summarize the lane-level road geometry extraction methods and mathematical modeling of a lane-level road network. They analyzed these two parts' methodologies, advantages, and limitations and discussed the classic logic formats of a lane-level road network.It can be found that lane count extraction is a critical step in lane construction, according to the above research methods. GMM uses prior knowledge of lanes. Thus, the methods based on GMM have higher robustness for low-precision trajectory data. However, the influence of vehicle lane-changing behavior is not considered in the GMM method, which leads to the differences between the actual trajectory distribution and the Gaussian mixture distribution. In addition, researchers usually use a one-dimensional classification method to extract the number of lanes. It can lead to variable lane width over the whole road segment. Road designers typically keep the number and width of lanes constant over a section of road. The results revealed that there was still room to improve the accuracy and precision of the lane geometry [22], although the crowdsourced trajectory method was economical.


## 3. Methodology

We propose a two-step algorithm that converts a set of trajectory data into a lane-level road map. Figure1 gives an overview of the method, which is detailed hereafter. The first step of the algorithm is vehicle lane-changing behavior recognition. At the end of this step, the lane-changing behaviors will be identified from vehicle trajectories. We select the trajectory segments with lane-changing behaviors to model the change of lane counts between adjacent road cross sections. In the second step, the lane counts and lane centerline nodes are extracted, and we connect these nodes to construct lane centerlines for each unidirectional road segment.Figure 1
Flowchart of lane information extraction.


### 3.1. Recognition of Lane-Changing Behavior

The recognition of lane-changing behavior is explained in the following sections.


#### 3.1.1. Lane-Changing Feature Extraction

Driving behavior can be divided into car-following and lane-changing behavior [23]. The car-following behavior refers to following the preceding vehicle in the same lane. The lane-changing behavior refers to the vehicle entering an adjacent lane to satisfy its driving purpose. In this paper, the trajectory with the former behavior is called the car-following trajectory segment, and the latter is called the lane-changing trajectory segment. It is clear that the points on a car-following trajectory segment are located in the same lane, and the points on a lane-changing trajectory segment will cross the adjacent lanes.We divide the vehicle trajectories into car-following and lane-changing trajectory segments in the Frenet coordinate system. Compared with other coordinate systems, the Frenet coordinate system can distinguish the vehicle’s motion state on the road from the geometric shape of the road itself. The Frenet coordinate system converts the two-dimensional motion of a vehicle in plane space into two one-dimensional motions in reference curve space. One-dimensional motion problems are more accessible to model and resolve than two-dimensional ones.Unlike the conventional Cartesian coordinate system, the Frenet coordinate system needs to be based on a given reference line to convert the absolute position of an object to the relative position of a reference line. The road centerline is selected as the reference line in a Frenet coordinate system, and the vehicle trajectories in the coordinate system are converted to the relative positions of the road centerline. The new trajectory points can directly reflect the state of vehicle motion on the road without being affected by road geometry.In the Frenet coordinate system, lateral and longitudinal displacements are used to represent the position of a vehicle. Assuming that the coordinates of a vehicle in a global coordinate system (Cartesian coordinate system or Geographic coordinate system) arePt(x, y). The projection is made from point Pt to road centerline Tref. Ps is the projection point. The distance between Ps and Pt is d. The curve distance from the starting point of Tref to Ps is s. d is the lateral displacement between the vehicle and the road centerline. s is the vehicle’s longitudinal displacement along the road centerline’s extension direction, as shown in Figure 2. Therefore, the vehicle’s coordinates in the Frenet coordinate system are Fr(s, d). Figure 3(a) shows the vehicle’s trajectory in Figure 2 using the Frenet coordinate system. Compared with the trajectory in the global coordinate system (Figure 3(b)), the shape of the vehicle trajectory curve in the Frenet coordinate system is more straightforward and intuitive. The ordinate of the curve can directly reflect the position information of the lane where the vehicle is located. Thus, it is easy to detect the lane-changing behavior of a vehicle in the Frenet coordinate system.Figure 2
Conversion from global coordinate system to Frenet coordinate system.Figure 3
Representation of vehicle trajectory curve in different coordinate systems: (a) vehicle trajectory in the Frenet coordinate system; (b) vehicle trajectory in the global coordinate system.
(a)(b)In the Frenet coordinate system, the car-following trajectory segment is a horizontal straight-line segment. The lane-changing trajectory segment is an “S”-shaped curve that crosses the adjacent lanes. Compared with the lane-changing trajectory segment, the lateral displacement of points on the car-following trajectory segment is similar, and the slope of each point is around zero. Therefore, they can be distinguished according to the lateral displacement and slope of the trajectory points. We select two indices to describe lane-changing features of trajectory points. One is the difference between the lateral displacement of neighborhood points. The other is the slope at the target trajectory point.Because a consumer-grade GPS equipped on a floating car usually has a significant positioning error, lane-changing features extracted by vehicle trajectory points are usually affected by the positioning error. Therefore, we use the moving least squares method [24] to fit the actual trajectory of a vehicle before extracting the lane-changing features. Compared with the original trajectory, the fitted trajectory is smoother and less affected by positioning errors. Lane-changing features extracted based on the fitted trajectory are more stable.


#### 3.1.2. Recognition of Lane-Changing Trajectory Points

After extracting the lane-changing features of each trajectory point, lane-changing trajectory points can be classified based on the features. We use theK-means algorithm to classify points and recognize lane-changing behavior for each trajectory. K-means is a common clustering algorithm widely used because of its simplicity and high efficiency. We chose this algorithm because the number of points on each trajectory is not very large and the number of clusters is determined. It should be noted that this paper mainly focuses on the accuracy of lane information extraction and does not consider the speed of algorithm execution. The distributed clustering algorithm can also be used to replace the traditional K-means algorithm, considering the algorithm’s efficiency. The lane-changing point recognition method based on K-means includes the following three steps:Step 1: Normalization of lane-changing eigenvalues. Since the two extracted lane-changing features are not uniform in dimension and the numerical ranges of the two features are inconsistent, it is necessary to normalize the lane-changing feature values. We use the min-max normalization method to make the values range from 0 to 1. Ifx is a set of feature values, the normalized x' can be calculated as follows:(1)x′=x−minxmaxx−minx.Step 2:K-means clustering of trajectory points. The sample set Sp = {Sp1, Sp2, …, Spn} is established according to the lane-changing features of trajectory points, where n is the number of trajectory points. The sample point Spi corresponds to the two normalized lane-changing eigenvalues v1 and v2 of the i-th trajectory point, namely Spi = (v1, v2), i = (1,2, …, n). Firstly, the two samples closest to the origin and the farthest samples in Sp are selected as the initial cluster centers. Then, calculate the distance between each sample and the two cluster centers, and assign each sample to the closest cluster. Each cluster center and the samples assigned to it represent a cluster. Once all samples have been allocated, the cluster centers are recalculated based on the samples contained in each cluster. The sample allocation and cluster center calculation process are repeated until no samples are reassigned to different clusters. Then the category to which each sample belongs is the final clustering result. The trajectory points corresponding to the samples are divided into two categories according to the final clustering results of the samples.Step 3: Determination of cluster category. After classifying trajectory points, the meaning of the point cluster category is further determined according to the location of the cluster center. Compared with nonlane-changing trajectory points, lane-changing trajectory points have larger eigenvalues. Therefore, the trajectory points whose cluster center is further from the coordinate origin are regarded as lane-changing, and the other points are regarded as nonlane-changing.


### 3.2. Construction of Lane-Level Map

The construction of lane-level map is explained in the following sections.


#### 3.2.1. Trajectory Distribution Modeling on the Road Cross Section

Lane centerlines can be extracted using a constrained Gaussian mixture model (CGMM) [13]. The basic principle is to analyze the density distribution of trajectory data on a road cross section. Constrained by the prior knowledge of lane distribution law, the trajectory density distribution is fitted on the premise of knowing the number of lanes. A lane’s centerline position and width can be determined by the fitted trajectory density distribution on a road cross section. Furthermore, the lane centerlines are obtained by the CGMM for multiple consecutive road cross sections.The CGMM method ignores the difference in positioning errors of vehicle trajectories. Tang et al. [15] found that some trajectories have high positioning accuracy while others have low accuracy on the same road. Therefore, we improve the original CGMM and propose a weighted constrained Gaussian mixture model (WCGMM). The weighted model considers the difference in trajectory positioning accuracy. Firstly, it estimates the positioning accuracy of trajectories. Then, the accuracy is taken as a weight in the original constrained Gaussian mixture model.Vehicles usually travel steadily along the extended direction of a road. Thus, the trajectory of a vehicle will be a smooth curve similar to the road’s centerline. When the positioning accuracy is low, the position deviation of points on the trajectory is significant. It results in a large difference between the trajectory shape and the shape of the road centerline. Therefore, we compare the similarity between the vehicle trajectory and the road centerline to estimate the positioning accuracy of trajectories. The similarity can be measured by the standard deviation of the distance between all points and the road centerline. When a trajectory’s shape is the same as the road centerline, the standard deviation of the distance between all the trajectory points and the road centerline is equal to 0. If the trajectory shape differs significantly from the road centerline, the standard deviation of the distance between all trajectory points and the road centerline is also significant. Figure4 visualizes the results of the standard deviation of the distance between the points and the road centerline. In this figure, the red trajectories have a more significant standard deviation, and the green trajectories have a minor standard deviation. It can be found that the positioning accuracy of a trajectory is positively correlated with the standard deviation of the distance between all trajectory points and the corresponding road centerline.Figure 4
Visualization of the standard deviation of the distance between trajectory points and the road centerline.Suppose the distances between the trajectory points and the corresponding road centerline ared1, d2, …, dn (n is the number of trajectory points), and the average of these distances is d¯. Then, the positioning accuracy ω of the trajectory can be calculated by equation (2). After estimating the positioning accuracy of each trajectory, a weighted constrained Gaussian mixture model is constructed based on the trajectories for each road cross section.(2)ω=n∑i=1ndi−d¯2.Before discussing the WCGMM method, we first introduce the basic concepts of the Gaussian mixture model (GMM). The GMM can be formulated by mixing multiple single Gaussian distributions. Every Gaussian distribution can be regarded as a component of the GMM. Therefore, the probability density distributionp(x|Θ) of the GMM can be expressed as(3)px|Θ=∑j=1KφjΨx|μj,σj,where Θ = {φ1, …, φK, θ1, …, θK} are parameters of the GMM. φ1, …, φK is the probability that the sample value x belongs to each component. The sum of all the probabilities is equal to 1. θj = {μj, σj} is the parameter of the j-th Gaussian component. μj is the mean, and σj is the standard deviation. K is the number of Gaussian components in the GMM. Ψ(x|μj, σj) is the probability density function of a single Gaussian distribution, and Ψ(x|μj, σj) can be expressed as(4)Ψx|μj,σj=12πσj2exp−x−μj22σj2.Gebru et al. [25] further introduced the concept of sample weights based on the GMM. It combines the sample weights and the GMM by treating the weight ω of sample x as ω times equivalent observations of x. Then, the probability density distribution p(x|Θ, ω) of the weighted GMM can be derived as(5)px|Θ,ω=∑j=1KφjΨx|μj,σjω.The weighted GMM can model the density distribution of vehicle trajectories on road cross sections. Sample valuex can be expressed as the position of a trajectory on the road cross section. ω is the estimated positioning accuracy of each trajectory segment. K can be expressed as the number of lanes. φj is equivalent to the ratio of lane traffic flow to roadway traffic flow. μj corresponds to the position of each lane centerline. σj is the dispersion of trajectories on each lane. σj is related to the width of a lane. According to urban road construction standards, the width of each lane on the same roadway should be equal. Thus, σj of every Gaussian distribution is the same in a weighted GMM, that is, σ1 = σ2 = ⋯ = σK = σ. We call the weighted GMM constrained by the same σ as the weighted constrained GMM (WCGMM). Lane-level road information can be obtained by solving the parameters of the model.The EM algorithm calculates the parameters of the WCGMM. The EM algorithm is widely used to solve the latent variable model. It can estimate the maximum likelihood probability, or posterior probability, of a latent variable model in an iterative manner. The maximum posterior probability method is used to estimate the parameters. To express model parameters in the iterative process of the EM algorithm, we represent model parameters Θ as (φj(m), μj(m), σ(m)), where m is the solution of the m-th iteration process. For the initial value of parameters in the first iteration, we set them as φ1(0) = φ2(0) = ⋯φK(0) = 1/K, and the setting of σ(0) can refer to the standard width of lanes. We set σ(0) to 1.75 meters and set the initially estimated position μj(0) by σ(0) and lanes number K.The above EM algorithm is divided into two steps: step E estimates the probability of each sample belonging to each Gaussian component. Step M updates the model parameters. We alternate the step E and step M iteratively to make the model gradually approach the maximum posterior probability. Among them, the calculation method of step E is(6)γijm=φjmΨxi|μjm,σ/ωim∑l=1KφlmΨxi|μlm,σ/ωim,where xi is the i-th sample value, ωi is the weight of xi, and γij(m) represents the probability that xi belongs to the j-th Gaussian component during the m-th iteration. Step M updates the parameters of the WCGMM according to the probabilities that each sample calculated in step E belongs to different Gaussian components. If the total number of samples is n, the calculation method is(7)φjm+1=∑i=1nγijmn,μjm+1=1∑i=1nωiγijm∑i=1nωiγijmxi,σm=1∑i=1nγijm∑i=1nωiγijmxi−μjm+12.When the number of lanes on a road cross section is known, the value of each unknown parameter can be calculated through the EM algorithm. Then the lane centerline and lane width can be estimated. Meanwhile, this model’s likelihood can be calculated using model parameters. The likelihood can be understood as the probability of the current trajectory state distribution under the conditions of the known number of lanes and model parameters. It can be expressed as equation (8). In the next section, we will use the log-likelihood of the model to extract the number of lanes.(8)LX|Θ,K=∏i=1npxi|Θ,ωi,K.


#### 3.2.2. Extraction of Lane Counts on Continuous Road Cross Sections

The ratio of vehicle lane-changing behavior between adjacent road cross sections is related to the number of lanes. If the number of lanes increases or decreases, many vehicles will change lanes. When the traffic volume of each lane is approximately the same, the changes in lane counts can be estimated by the ratio of lane-changing vehicles to all vehicles on the road segment. As shown in Figure5, when the number of lanes changes from two to three, two of the three lanes on road cross section G is the continuation of the two lanes on road cross section F. The remaining one is the newly added lane. Vehicles on the newly-added lane must go through a lane change to reach the newly-added lane. Therefore, the number of lanes changes from F to G can be estimated by counting the ratio of vehicles that have caused lane-changing behavior.Figure 5
The relationship between lane-changing behavior and the lane counts.Under the premise that trajectory distribution on the road and the number of lane-changing vehicles are known, the lane counts estimation can be modeled by the hidden Markov model (HMM). HMM is a Markov process with hidden states and observations [26]. Each state has an observation probability for the possible observations. The transition probability defines the state-to-state transition. The hidden state sequence can be generated by maximizing the overall probability given a series of observations. HMM mainly includes five elements, namely two state sets and three probability matrices [27]:Hidden state H: the hidden state in HMM cannot be obtained by direct observation. These states satisfy the Markov property. Each hidden state is only related to its neighboring hidden states.Observation state O: A state that can be obtained by direct observation and is related to an implicit state in HMM.State transition matrixB: the matrix describes the transition probability between the hidden states in HMM. B = [bij]M×M, where bij = P(ht+1 = Hj|ht = Hi), 1 ≤ i, j ≤ M, and M is the number of hidden states. bij represents the probability that the hidden state is Hj at t + 1, and the hidden state is Hi at t.Observation state matrixC: this matrix describes the probability of the current observation state under the condition that the hidden state is known. C = [cj(k)]M×N, where cj(k) = P(ot = Ok|ht = Hj), 1 ≤ k ≤ N, N is the number of observation states. cj(k) represents the probability that the observed state is Ok, and the hidden state is Hj at time t.The initial state matrixη: η = (ηi), ηi = P(h1 = Hi), 1 ≤ i ≤ N. It represents the probability matrix of the hidden state at the initial time t = 1.The number of lanes at multiple road cross sections can be considered a Markov process. It means the number of lanes at each road cross section is only related to adjacent road cross sections. Therefore, the HMM model can be established by taking the number of lanes on multiple consecutive road cross sections as the hidden state, assuming that the number of lanes at multiple consecutive road cross sections isH = {h1, h2, …, hT}, where T is the number of road cross sections. The trajectory distribution can model the observation state O on each road cross section, namely O = {o1, o2, …, oT}. According to the fitting result of the WCGMM on the trajectory distribution, the observation state matrix C can be calculated. Each element cj(k) in C can be expressed as(9)cjk=lnLOk|Θ,Hj,where L(Ok|Θ, Hj) is the likelihood of the WCGMM under the condition that the number of lanes is Hj. It can be calculated by equation (8). The value of this probability is usually minimal because the probability is in the form of multiplication of multiple probabilities. Therefore, we use the log-likelihood to calculate the observation state. The maximum log-likelihood of all observation states is used for the min-max normalization to facilitate computer processing.The state transition matrixB can be defined according to the ratio of the lane-changing vehicle. Each element bij in B can be expressed as(10)bij=Pht+1=Hj|ht=Hi=exp−Hi−Hj−βt,t+1⋅maxHi,Hj2,where βt,t+1 is the ratio of lane-changing vehicles between the t and t + 1 road cross sections. The product of βt,t+1, and the maximum number of lanes on the adjacent road cross section is the number of changing lanes. According to the difference between hidden states Hi and Hj, the number of changing lanes can also be obtained. Therefore, the probability of lane counts on the current and previous road cross sections is Hj and Hi, which can be calculated according to the number of changing lanes. Taking into account that some vehicles may change lanes due to the need to overtake or turn even if there is no new lane, βt,t+1 is expressed as(11)βt,t+1=CGleft−CGrightCRtotal,where CGleft and CGright represent the number of vehicles changing lanes to the left and right, respectively. CRtotal represents the number of all vehicles between two adjacent road cross sections. βt,t+1 is calculated this way because the probability of vehicles changing to the left and right sides is considered equal when no additional lanes exist. Using the difference in the number of vehicles changing lanes to the left and right can avoid the influence of overtaking or turning.The number of lane-changing vehicles can be extracted according to the lane-change trajectory points identified in Section3.1. First, we count all lane-change trajectory points between two adjacent road cross sections. Then these points are classified into left and right categories according to the change in direction. Finally, the number of vehicles changing direction to the left or right is counted by the vehicle’s ID of trajectory points.The observed state probability can directly represent the initial state matrix. We take the maximum number of lanes as a parameter of the algorithm, and the candidate set of hidden state variables can be determined according to the maximum number of lanes. The solution to the hidden state in HMM is to find the number of lanes on each road cross section with the most significant overall probability. Generally, it can be solved by the Viterbi algorithm [28]. After using the Viterbi algorithm to find the number of lanes in each road cross section, the WCGMM corresponding to each road cross section can be determined. Then the lane information on a road cross section can be obtained using model parameters.


#### 3.2.3. Extraction of Lane Centerlines

The HMM and the WCGMM can generate lane centerline nodes on road cross sections. Then, we need to construct lane centerlines by connecting these nodes on multiple consecutive road cross sections. To make the constructed lane centerlines as close to the actual lane centerlines as possible, we need to divide the road into as many cross sections as possible. These multiple road cross sections are set along the centerline of a road at a fixed length interval to extract the lane centerline nodes. We take the fixed-length interval of road cross sections as a parameter of the algorithm. Then, we can extract multiple-lane centerline nodes with more than two lanes on one road cross section. Besides, the number of centerline nodes on adjacent road cross sections may differ when lanes change. It is necessary to determine which two nodes on the adjacent road cross sections need to be connected. A method for connecting lane centerline nodes is proposed based on the minimum matching distance, which includes the following steps:Step 1: Index the lane centerline nodes. Sort the nodes on a cross section according to the distance between the node and the road’s centerline. Then number the nodes according to the sort order. As shown in Figure6, for the nodes on road cross section G, the closest node to the centerline is G1, followed by G2 and G3, until the n-th node is Gn.Step 2: Build a candidate match set. Since the number of lanes on two adjacent road cross sections may differ, we use the road cross section with fewer lanes as a reference. Then we match the nodes on the cross section with more lanes on the reference road cross section. If two adjacent road cross sections areF and G, then the number of lanes in F is m, the lane counts in G is n, and m < n. Therefore, the set of nodes in F is FNode = {F1, F2, …, Fm}, and the set of nodes in G is GNode = {G1, G2, …, Gn}. According to the node index in G, the candidate matching set for FNode is constructed. Each candidate matching set for FNode is {Gi, Gi+1, …, Gi+m−1}, with i from 1 to n + 1 − m. According to each candidate matching set, a matching pair can be constructed, that is, F1 matches Gi, F2 matches Gi+1, and Fm matches Gi+m−1.Step 3: Calculate the matching distance. For each candidate matching set, we calculate the distance of each matching pair in the matching set. Then we calculate the sum of all distances for each matching pair. The sum is the matching distance of the whole candidate matching set.Step 4: Construct the centerlines of lanes. The candidate matching set with the smallest matching distance is selected. We connect the corresponding nodes according to each matching pair, as shown by the solid red line in Figure7. For the unmatched node Gu on road cross section G, we find the closest matching node Gv on G. Then we connect Gu to the corresponding matching node of Gv on road cross section F, as shown by the red dashed line in Figure 7.Figure 6
Lane centerline node index.Figure 7
Lane centerline node connection.


## 3.1. Recognition of Lane-Changing Behavior

The recognition of lane-changing behavior is explained in the following sections.


### 3.1.1. Lane-Changing Feature Extraction

Driving behavior can be divided into car-following and lane-changing behavior [23]. The car-following behavior refers to following the preceding vehicle in the same lane. The lane-changing behavior refers to the vehicle entering an adjacent lane to satisfy its driving purpose. In this paper, the trajectory with the former behavior is called the car-following trajectory segment, and the latter is called the lane-changing trajectory segment. It is clear that the points on a car-following trajectory segment are located in the same lane, and the points on a lane-changing trajectory segment will cross the adjacent lanes.We divide the vehicle trajectories into car-following and lane-changing trajectory segments in the Frenet coordinate system. Compared with other coordinate systems, the Frenet coordinate system can distinguish the vehicle’s motion state on the road from the geometric shape of the road itself. The Frenet coordinate system converts the two-dimensional motion of a vehicle in plane space into two one-dimensional motions in reference curve space. One-dimensional motion problems are more accessible to model and resolve than two-dimensional ones.Unlike the conventional Cartesian coordinate system, the Frenet coordinate system needs to be based on a given reference line to convert the absolute position of an object to the relative position of a reference line. The road centerline is selected as the reference line in a Frenet coordinate system, and the vehicle trajectories in the coordinate system are converted to the relative positions of the road centerline. The new trajectory points can directly reflect the state of vehicle motion on the road without being affected by road geometry.In the Frenet coordinate system, lateral and longitudinal displacements are used to represent the position of a vehicle. Assuming that the coordinates of a vehicle in a global coordinate system (Cartesian coordinate system or Geographic coordinate system) arePt(x, y). The projection is made from point Pt to road centerline Tref. Ps is the projection point. The distance between Ps and Pt is d. The curve distance from the starting point of Tref to Ps is s. d is the lateral displacement between the vehicle and the road centerline. s is the vehicle’s longitudinal displacement along the road centerline’s extension direction, as shown in Figure 2. Therefore, the vehicle’s coordinates in the Frenet coordinate system are Fr(s, d). Figure 3(a) shows the vehicle’s trajectory in Figure 2 using the Frenet coordinate system. Compared with the trajectory in the global coordinate system (Figure 3(b)), the shape of the vehicle trajectory curve in the Frenet coordinate system is more straightforward and intuitive. The ordinate of the curve can directly reflect the position information of the lane where the vehicle is located. Thus, it is easy to detect the lane-changing behavior of a vehicle in the Frenet coordinate system.Figure 2
Conversion from global coordinate system to Frenet coordinate system.Figure 3
Representation of vehicle trajectory curve in different coordinate systems: (a) vehicle trajectory in the Frenet coordinate system; (b) vehicle trajectory in the global coordinate system.
(a)(b)In the Frenet coordinate system, the car-following trajectory segment is a horizontal straight-line segment. The lane-changing trajectory segment is an “S”-shaped curve that crosses the adjacent lanes. Compared with the lane-changing trajectory segment, the lateral displacement of points on the car-following trajectory segment is similar, and the slope of each point is around zero. Therefore, they can be distinguished according to the lateral displacement and slope of the trajectory points. We select two indices to describe lane-changing features of trajectory points. One is the difference between the lateral displacement of neighborhood points. The other is the slope at the target trajectory point.Because a consumer-grade GPS equipped on a floating car usually has a significant positioning error, lane-changing features extracted by vehicle trajectory points are usually affected by the positioning error. Therefore, we use the moving least squares method [24] to fit the actual trajectory of a vehicle before extracting the lane-changing features. Compared with the original trajectory, the fitted trajectory is smoother and less affected by positioning errors. Lane-changing features extracted based on the fitted trajectory are more stable.


### 3.1.2. Recognition of Lane-Changing Trajectory Points

After extracting the lane-changing features of each trajectory point, lane-changing trajectory points can be classified based on the features. We use theK-means algorithm to classify points and recognize lane-changing behavior for each trajectory. K-means is a common clustering algorithm widely used because of its simplicity and high efficiency. We chose this algorithm because the number of points on each trajectory is not very large and the number of clusters is determined. It should be noted that this paper mainly focuses on the accuracy of lane information extraction and does not consider the speed of algorithm execution. The distributed clustering algorithm can also be used to replace the traditional K-means algorithm, considering the algorithm’s efficiency. The lane-changing point recognition method based on K-means includes the following three steps:Step 1: Normalization of lane-changing eigenvalues. Since the two extracted lane-changing features are not uniform in dimension and the numerical ranges of the two features are inconsistent, it is necessary to normalize the lane-changing feature values. We use the min-max normalization method to make the values range from 0 to 1. Ifx is a set of feature values, the normalized x' can be calculated as follows:(1)x′=x−minxmaxx−minx.Step 2:K-means clustering of trajectory points. The sample set Sp = {Sp1, Sp2, …, Spn} is established according to the lane-changing features of trajectory points, where n is the number of trajectory points. The sample point Spi corresponds to the two normalized lane-changing eigenvalues v1 and v2 of the i-th trajectory point, namely Spi = (v1, v2), i = (1,2, …, n). Firstly, the two samples closest to the origin and the farthest samples in Sp are selected as the initial cluster centers. Then, calculate the distance between each sample and the two cluster centers, and assign each sample to the closest cluster. Each cluster center and the samples assigned to it represent a cluster. Once all samples have been allocated, the cluster centers are recalculated based on the samples contained in each cluster. The sample allocation and cluster center calculation process are repeated until no samples are reassigned to different clusters. Then the category to which each sample belongs is the final clustering result. The trajectory points corresponding to the samples are divided into two categories according to the final clustering results of the samples.Step 3: Determination of cluster category. After classifying trajectory points, the meaning of the point cluster category is further determined according to the location of the cluster center. Compared with nonlane-changing trajectory points, lane-changing trajectory points have larger eigenvalues. Therefore, the trajectory points whose cluster center is further from the coordinate origin are regarded as lane-changing, and the other points are regarded as nonlane-changing.


## 3.1.1. Lane-Changing Feature Extraction

Driving behavior can be divided into car-following and lane-changing behavior [23]. The car-following behavior refers to following the preceding vehicle in the same lane. The lane-changing behavior refers to the vehicle entering an adjacent lane to satisfy its driving purpose. In this paper, the trajectory with the former behavior is called the car-following trajectory segment, and the latter is called the lane-changing trajectory segment. It is clear that the points on a car-following trajectory segment are located in the same lane, and the points on a lane-changing trajectory segment will cross the adjacent lanes.We divide the vehicle trajectories into car-following and lane-changing trajectory segments in the Frenet coordinate system. Compared with other coordinate systems, the Frenet coordinate system can distinguish the vehicle’s motion state on the road from the geometric shape of the road itself. The Frenet coordinate system converts the two-dimensional motion of a vehicle in plane space into two one-dimensional motions in reference curve space. One-dimensional motion problems are more accessible to model and resolve than two-dimensional ones.Unlike the conventional Cartesian coordinate system, the Frenet coordinate system needs to be based on a given reference line to convert the absolute position of an object to the relative position of a reference line. The road centerline is selected as the reference line in a Frenet coordinate system, and the vehicle trajectories in the coordinate system are converted to the relative positions of the road centerline. The new trajectory points can directly reflect the state of vehicle motion on the road without being affected by road geometry.In the Frenet coordinate system, lateral and longitudinal displacements are used to represent the position of a vehicle. Assuming that the coordinates of a vehicle in a global coordinate system (Cartesian coordinate system or Geographic coordinate system) arePt(x, y). The projection is made from point Pt to road centerline Tref. Ps is the projection point. The distance between Ps and Pt is d. The curve distance from the starting point of Tref to Ps is s. d is the lateral displacement between the vehicle and the road centerline. s is the vehicle’s longitudinal displacement along the road centerline’s extension direction, as shown in Figure 2. Therefore, the vehicle’s coordinates in the Frenet coordinate system are Fr(s, d). Figure 3(a) shows the vehicle’s trajectory in Figure 2 using the Frenet coordinate system. Compared with the trajectory in the global coordinate system (Figure 3(b)), the shape of the vehicle trajectory curve in the Frenet coordinate system is more straightforward and intuitive. The ordinate of the curve can directly reflect the position information of the lane where the vehicle is located. Thus, it is easy to detect the lane-changing behavior of a vehicle in the Frenet coordinate system.Figure 2
Conversion from global coordinate system to Frenet coordinate system.Figure 3
Representation of vehicle trajectory curve in different coordinate systems: (a) vehicle trajectory in the Frenet coordinate system; (b) vehicle trajectory in the global coordinate system.
(a)(b)In the Frenet coordinate system, the car-following trajectory segment is a horizontal straight-line segment. The lane-changing trajectory segment is an “S”-shaped curve that crosses the adjacent lanes. Compared with the lane-changing trajectory segment, the lateral displacement of points on the car-following trajectory segment is similar, and the slope of each point is around zero. Therefore, they can be distinguished according to the lateral displacement and slope of the trajectory points. We select two indices to describe lane-changing features of trajectory points. One is the difference between the lateral displacement of neighborhood points. The other is the slope at the target trajectory point.Because a consumer-grade GPS equipped on a floating car usually has a significant positioning error, lane-changing features extracted by vehicle trajectory points are usually affected by the positioning error. Therefore, we use the moving least squares method [24] to fit the actual trajectory of a vehicle before extracting the lane-changing features. Compared with the original trajectory, the fitted trajectory is smoother and less affected by positioning errors. Lane-changing features extracted based on the fitted trajectory are more stable.


## 3.1.2. Recognition of Lane-Changing Trajectory Points

After extracting the lane-changing features of each trajectory point, lane-changing trajectory points can be classified based on the features. We use theK-means algorithm to classify points and recognize lane-changing behavior for each trajectory. K-means is a common clustering algorithm widely used because of its simplicity and high efficiency. We chose this algorithm because the number of points on each trajectory is not very large and the number of clusters is determined. It should be noted that this paper mainly focuses on the accuracy of lane information extraction and does not consider the speed of algorithm execution. The distributed clustering algorithm can also be used to replace the traditional K-means algorithm, considering the algorithm’s efficiency. The lane-changing point recognition method based on K-means includes the following three steps:Step 1: Normalization of lane-changing eigenvalues. Since the two extracted lane-changing features are not uniform in dimension and the numerical ranges of the two features are inconsistent, it is necessary to normalize the lane-changing feature values. We use the min-max normalization method to make the values range from 0 to 1. Ifx is a set of feature values, the normalized x' can be calculated as follows:(1)x′=x−minxmaxx−minx.Step 2:K-means clustering of trajectory points. The sample set Sp = {Sp1, Sp2, …, Spn} is established according to the lane-changing features of trajectory points, where n is the number of trajectory points. The sample point Spi corresponds to the two normalized lane-changing eigenvalues v1 and v2 of the i-th trajectory point, namely Spi = (v1, v2), i = (1,2, …, n). Firstly, the two samples closest to the origin and the farthest samples in Sp are selected as the initial cluster centers. Then, calculate the distance between each sample and the two cluster centers, and assign each sample to the closest cluster. Each cluster center and the samples assigned to it represent a cluster. Once all samples have been allocated, the cluster centers are recalculated based on the samples contained in each cluster. The sample allocation and cluster center calculation process are repeated until no samples are reassigned to different clusters. Then the category to which each sample belongs is the final clustering result. The trajectory points corresponding to the samples are divided into two categories according to the final clustering results of the samples.Step 3: Determination of cluster category. After classifying trajectory points, the meaning of the point cluster category is further determined according to the location of the cluster center. Compared with nonlane-changing trajectory points, lane-changing trajectory points have larger eigenvalues. Therefore, the trajectory points whose cluster center is further from the coordinate origin are regarded as lane-changing, and the other points are regarded as nonlane-changing.


## 3.2. Construction of Lane-Level Map

The construction of lane-level map is explained in the following sections.


### 3.2.1. Trajectory Distribution Modeling on the Road Cross Section

Lane centerlines can be extracted using a constrained Gaussian mixture model (CGMM) [13]. The basic principle is to analyze the density distribution of trajectory data on a road cross section. Constrained by the prior knowledge of lane distribution law, the trajectory density distribution is fitted on the premise of knowing the number of lanes. A lane’s centerline position and width can be determined by the fitted trajectory density distribution on a road cross section. Furthermore, the lane centerlines are obtained by the CGMM for multiple consecutive road cross sections.The CGMM method ignores the difference in positioning errors of vehicle trajectories. Tang et al. [15] found that some trajectories have high positioning accuracy while others have low accuracy on the same road. Therefore, we improve the original CGMM and propose a weighted constrained Gaussian mixture model (WCGMM). The weighted model considers the difference in trajectory positioning accuracy. Firstly, it estimates the positioning accuracy of trajectories. Then, the accuracy is taken as a weight in the original constrained Gaussian mixture model.Vehicles usually travel steadily along the extended direction of a road. Thus, the trajectory of a vehicle will be a smooth curve similar to the road’s centerline. When the positioning accuracy is low, the position deviation of points on the trajectory is significant. It results in a large difference between the trajectory shape and the shape of the road centerline. Therefore, we compare the similarity between the vehicle trajectory and the road centerline to estimate the positioning accuracy of trajectories. The similarity can be measured by the standard deviation of the distance between all points and the road centerline. When a trajectory’s shape is the same as the road centerline, the standard deviation of the distance between all the trajectory points and the road centerline is equal to 0. If the trajectory shape differs significantly from the road centerline, the standard deviation of the distance between all trajectory points and the road centerline is also significant. Figure4 visualizes the results of the standard deviation of the distance between the points and the road centerline. In this figure, the red trajectories have a more significant standard deviation, and the green trajectories have a minor standard deviation. It can be found that the positioning accuracy of a trajectory is positively correlated with the standard deviation of the distance between all trajectory points and the corresponding road centerline.Figure 4
Visualization of the standard deviation of the distance between trajectory points and the road centerline.Suppose the distances between the trajectory points and the corresponding road centerline ared1, d2, …, dn (n is the number of trajectory points), and the average of these distances is d¯. Then, the positioning accuracy ω of the trajectory can be calculated by equation (2). After estimating the positioning accuracy of each trajectory, a weighted constrained Gaussian mixture model is constructed based on the trajectories for each road cross section.(2)ω=n∑i=1ndi−d¯2.Before discussing the WCGMM method, we first introduce the basic concepts of the Gaussian mixture model (GMM). The GMM can be formulated by mixing multiple single Gaussian distributions. Every Gaussian distribution can be regarded as a component of the GMM. Therefore, the probability density distributionp(x|Θ) of the GMM can be expressed as(3)px|Θ=∑j=1KφjΨx|μj,σj,where Θ = {φ1, …, φK, θ1, …, θK} are parameters of the GMM. φ1, …, φK is the probability that the sample value x belongs to each component. The sum of all the probabilities is equal to 1. θj = {μj, σj} is the parameter of the j-th Gaussian component. μj is the mean, and σj is the standard deviation. K is the number of Gaussian components in the GMM. Ψ(x|μj, σj) is the probability density function of a single Gaussian distribution, and Ψ(x|μj, σj) can be expressed as(4)Ψx|μj,σj=12πσj2exp−x−μj22σj2.Gebru et al. [25] further introduced the concept of sample weights based on the GMM. It combines the sample weights and the GMM by treating the weight ω of sample x as ω times equivalent observations of x. Then, the probability density distribution p(x|Θ, ω) of the weighted GMM can be derived as(5)px|Θ,ω=∑j=1KφjΨx|μj,σjω.The weighted GMM can model the density distribution of vehicle trajectories on road cross sections. Sample valuex can be expressed as the position of a trajectory on the road cross section. ω is the estimated positioning accuracy of each trajectory segment. K can be expressed as the number of lanes. φj is equivalent to the ratio of lane traffic flow to roadway traffic flow. μj corresponds to the position of each lane centerline. σj is the dispersion of trajectories on each lane. σj is related to the width of a lane. According to urban road construction standards, the width of each lane on the same roadway should be equal. Thus, σj of every Gaussian distribution is the same in a weighted GMM, that is, σ1 = σ2 = ⋯ = σK = σ. We call the weighted GMM constrained by the same σ as the weighted constrained GMM (WCGMM). Lane-level road information can be obtained by solving the parameters of the model.The EM algorithm calculates the parameters of the WCGMM. The EM algorithm is widely used to solve the latent variable model. It can estimate the maximum likelihood probability, or posterior probability, of a latent variable model in an iterative manner. The maximum posterior probability method is used to estimate the parameters. To express model parameters in the iterative process of the EM algorithm, we represent model parameters Θ as (φj(m), μj(m), σ(m)), where m is the solution of the m-th iteration process. For the initial value of parameters in the first iteration, we set them as φ1(0) = φ2(0) = ⋯φK(0) = 1/K, and the setting of σ(0) can refer to the standard width of lanes. We set σ(0) to 1.75 meters and set the initially estimated position μj(0) by σ(0) and lanes number K.The above EM algorithm is divided into two steps: step E estimates the probability of each sample belonging to each Gaussian component. Step M updates the model parameters. We alternate the step E and step M iteratively to make the model gradually approach the maximum posterior probability. Among them, the calculation method of step E is(6)γijm=φjmΨxi|μjm,σ/ωim∑l=1KφlmΨxi|μlm,σ/ωim,where xi is the i-th sample value, ωi is the weight of xi, and γij(m) represents the probability that xi belongs to the j-th Gaussian component during the m-th iteration. Step M updates the parameters of the WCGMM according to the probabilities that each sample calculated in step E belongs to different Gaussian components. If the total number of samples is n, the calculation method is(7)φjm+1=∑i=1nγijmn,μjm+1=1∑i=1nωiγijm∑i=1nωiγijmxi,σm=1∑i=1nγijm∑i=1nωiγijmxi−μjm+12.When the number of lanes on a road cross section is known, the value of each unknown parameter can be calculated through the EM algorithm. Then the lane centerline and lane width can be estimated. Meanwhile, this model’s likelihood can be calculated using model parameters. The likelihood can be understood as the probability of the current trajectory state distribution under the conditions of the known number of lanes and model parameters. It can be expressed as equation (8). In the next section, we will use the log-likelihood of the model to extract the number of lanes.(8)LX|Θ,K=∏i=1npxi|Θ,ωi,K.


### 3.2.2. Extraction of Lane Counts on Continuous Road Cross Sections

The ratio of vehicle lane-changing behavior between adjacent road cross sections is related to the number of lanes. If the number of lanes increases or decreases, many vehicles will change lanes. When the traffic volume of each lane is approximately the same, the changes in lane counts can be estimated by the ratio of lane-changing vehicles to all vehicles on the road segment. As shown in Figure5, when the number of lanes changes from two to three, two of the three lanes on road cross section G is the continuation of the two lanes on road cross section F. The remaining one is the newly added lane. Vehicles on the newly-added lane must go through a lane change to reach the newly-added lane. Therefore, the number of lanes changes from F to G can be estimated by counting the ratio of vehicles that have caused lane-changing behavior.Figure 5
The relationship between lane-changing behavior and the lane counts.Under the premise that trajectory distribution on the road and the number of lane-changing vehicles are known, the lane counts estimation can be modeled by the hidden Markov model (HMM). HMM is a Markov process with hidden states and observations [26]. Each state has an observation probability for the possible observations. The transition probability defines the state-to-state transition. The hidden state sequence can be generated by maximizing the overall probability given a series of observations. HMM mainly includes five elements, namely two state sets and three probability matrices [27]:Hidden state H: the hidden state in HMM cannot be obtained by direct observation. These states satisfy the Markov property. Each hidden state is only related to its neighboring hidden states.Observation state O: A state that can be obtained by direct observation and is related to an implicit state in HMM.State transition matrixB: the matrix describes the transition probability between the hidden states in HMM. B = [bij]M×M, where bij = P(ht+1 = Hj|ht = Hi), 1 ≤ i, j ≤ M, and M is the number of hidden states. bij represents the probability that the hidden state is Hj at t + 1, and the hidden state is Hi at t.Observation state matrixC: this matrix describes the probability of the current observation state under the condition that the hidden state is known. C = [cj(k)]M×N, where cj(k) = P(ot = Ok|ht = Hj), 1 ≤ k ≤ N, N is the number of observation states. cj(k) represents the probability that the observed state is Ok, and the hidden state is Hj at time t.The initial state matrixη: η = (ηi), ηi = P(h1 = Hi), 1 ≤ i ≤ N. It represents the probability matrix of the hidden state at the initial time t = 1.The number of lanes at multiple road cross sections can be considered a Markov process. It means the number of lanes at each road cross section is only related to adjacent road cross sections. Therefore, the HMM model can be established by taking the number of lanes on multiple consecutive road cross sections as the hidden state, assuming that the number of lanes at multiple consecutive road cross sections isH = {h1, h2, …, hT}, where T is the number of road cross sections. The trajectory distribution can model the observation state O on each road cross section, namely O = {o1, o2, …, oT}. According to the fitting result of the WCGMM on the trajectory distribution, the observation state matrix C can be calculated. Each element cj(k) in C can be expressed as(9)cjk=lnLOk|Θ,Hj,where L(Ok|Θ, Hj) is the likelihood of the WCGMM under the condition that the number of lanes is Hj. It can be calculated by equation (8). The value of this probability is usually minimal because the probability is in the form of multiplication of multiple probabilities. Therefore, we use the log-likelihood to calculate the observation state. The maximum log-likelihood of all observation states is used for the min-max normalization to facilitate computer processing.The state transition matrixB can be defined according to the ratio of the lane-changing vehicle. Each element bij in B can be expressed as(10)bij=Pht+1=Hj|ht=Hi=exp−Hi−Hj−βt,t+1⋅maxHi,Hj2,where βt,t+1 is the ratio of lane-changing vehicles between the t and t + 1 road cross sections. The product of βt,t+1, and the maximum number of lanes on the adjacent road cross section is the number of changing lanes. According to the difference between hidden states Hi and Hj, the number of changing lanes can also be obtained. Therefore, the probability of lane counts on the current and previous road cross sections is Hj and Hi, which can be calculated according to the number of changing lanes. Taking into account that some vehicles may change lanes due to the need to overtake or turn even if there is no new lane, βt,t+1 is expressed as(11)βt,t+1=CGleft−CGrightCRtotal,where CGleft and CGright represent the number of vehicles changing lanes to the left and right, respectively. CRtotal represents the number of all vehicles between two adjacent road cross sections. βt,t+1 is calculated this way because the probability of vehicles changing to the left and right sides is considered equal when no additional lanes exist. Using the difference in the number of vehicles changing lanes to the left and right can avoid the influence of overtaking or turning.The number of lane-changing vehicles can be extracted according to the lane-change trajectory points identified in Section3.1. First, we count all lane-change trajectory points between two adjacent road cross sections. Then these points are classified into left and right categories according to the change in direction. Finally, the number of vehicles changing direction to the left or right is counted by the vehicle’s ID of trajectory points.The observed state probability can directly represent the initial state matrix. We take the maximum number of lanes as a parameter of the algorithm, and the candidate set of hidden state variables can be determined according to the maximum number of lanes. The solution to the hidden state in HMM is to find the number of lanes on each road cross section with the most significant overall probability. Generally, it can be solved by the Viterbi algorithm [28]. After using the Viterbi algorithm to find the number of lanes in each road cross section, the WCGMM corresponding to each road cross section can be determined. Then the lane information on a road cross section can be obtained using model parameters.


### 3.2.3. Extraction of Lane Centerlines

The HMM and the WCGMM can generate lane centerline nodes on road cross sections. Then, we need to construct lane centerlines by connecting these nodes on multiple consecutive road cross sections. To make the constructed lane centerlines as close to the actual lane centerlines as possible, we need to divide the road into as many cross sections as possible. These multiple road cross sections are set along the centerline of a road at a fixed length interval to extract the lane centerline nodes. We take the fixed-length interval of road cross sections as a parameter of the algorithm. Then, we can extract multiple-lane centerline nodes with more than two lanes on one road cross section. Besides, the number of centerline nodes on adjacent road cross sections may differ when lanes change. It is necessary to determine which two nodes on the adjacent road cross sections need to be connected. A method for connecting lane centerline nodes is proposed based on the minimum matching distance, which includes the following steps:Step 1: Index the lane centerline nodes. Sort the nodes on a cross section according to the distance between the node and the road’s centerline. Then number the nodes according to the sort order. As shown in Figure6, for the nodes on road cross section G, the closest node to the centerline is G1, followed by G2 and G3, until the n-th node is Gn.Step 2: Build a candidate match set. Since the number of lanes on two adjacent road cross sections may differ, we use the road cross section with fewer lanes as a reference. Then we match the nodes on the cross section with more lanes on the reference road cross section. If two adjacent road cross sections areF and G, then the number of lanes in F is m, the lane counts in G is n, and m < n. Therefore, the set of nodes in F is FNode = {F1, F2, …, Fm}, and the set of nodes in G is GNode = {G1, G2, …, Gn}. According to the node index in G, the candidate matching set for FNode is constructed. Each candidate matching set for FNode is {Gi, Gi+1, …, Gi+m−1}, with i from 1 to n + 1 − m. According to each candidate matching set, a matching pair can be constructed, that is, F1 matches Gi, F2 matches Gi+1, and Fm matches Gi+m−1.Step 3: Calculate the matching distance. For each candidate matching set, we calculate the distance of each matching pair in the matching set. Then we calculate the sum of all distances for each matching pair. The sum is the matching distance of the whole candidate matching set.Step 4: Construct the centerlines of lanes. The candidate matching set with the smallest matching distance is selected. We connect the corresponding nodes according to each matching pair, as shown by the solid red line in Figure7. For the unmatched node Gu on road cross section G, we find the closest matching node Gv on G. Then we connect Gu to the corresponding matching node of Gv on road cross section F, as shown by the red dashed line in Figure 7.Figure 6
Lane centerline node index.Figure 7
Lane centerline node connection.


## 3.2.1. Trajectory Distribution Modeling on the Road Cross Section

Lane centerlines can be extracted using a constrained Gaussian mixture model (CGMM) [13]. The basic principle is to analyze the density distribution of trajectory data on a road cross section. Constrained by the prior knowledge of lane distribution law, the trajectory density distribution is fitted on the premise of knowing the number of lanes. A lane’s centerline position and width can be determined by the fitted trajectory density distribution on a road cross section. Furthermore, the lane centerlines are obtained by the CGMM for multiple consecutive road cross sections.The CGMM method ignores the difference in positioning errors of vehicle trajectories. Tang et al. [15] found that some trajectories have high positioning accuracy while others have low accuracy on the same road. Therefore, we improve the original CGMM and propose a weighted constrained Gaussian mixture model (WCGMM). The weighted model considers the difference in trajectory positioning accuracy. Firstly, it estimates the positioning accuracy of trajectories. Then, the accuracy is taken as a weight in the original constrained Gaussian mixture model.Vehicles usually travel steadily along the extended direction of a road. Thus, the trajectory of a vehicle will be a smooth curve similar to the road’s centerline. When the positioning accuracy is low, the position deviation of points on the trajectory is significant. It results in a large difference between the trajectory shape and the shape of the road centerline. Therefore, we compare the similarity between the vehicle trajectory and the road centerline to estimate the positioning accuracy of trajectories. The similarity can be measured by the standard deviation of the distance between all points and the road centerline. When a trajectory’s shape is the same as the road centerline, the standard deviation of the distance between all the trajectory points and the road centerline is equal to 0. If the trajectory shape differs significantly from the road centerline, the standard deviation of the distance between all trajectory points and the road centerline is also significant. Figure4 visualizes the results of the standard deviation of the distance between the points and the road centerline. In this figure, the red trajectories have a more significant standard deviation, and the green trajectories have a minor standard deviation. It can be found that the positioning accuracy of a trajectory is positively correlated with the standard deviation of the distance between all trajectory points and the corresponding road centerline.Figure 4
Visualization of the standard deviation of the distance between trajectory points and the road centerline.Suppose the distances between the trajectory points and the corresponding road centerline ared1, d2, …, dn (n is the number of trajectory points), and the average of these distances is d¯. Then, the positioning accuracy ω of the trajectory can be calculated by equation (2). After estimating the positioning accuracy of each trajectory, a weighted constrained Gaussian mixture model is constructed based on the trajectories for each road cross section.(2)ω=n∑i=1ndi−d¯2.Before discussing the WCGMM method, we first introduce the basic concepts of the Gaussian mixture model (GMM). The GMM can be formulated by mixing multiple single Gaussian distributions. Every Gaussian distribution can be regarded as a component of the GMM. Therefore, the probability density distributionp(x|Θ) of the GMM can be expressed as(3)px|Θ=∑j=1KφjΨx|μj,σj,where Θ = {φ1, …, φK, θ1, …, θK} are parameters of the GMM. φ1, …, φK is the probability that the sample value x belongs to each component. The sum of all the probabilities is equal to 1. θj = {μj, σj} is the parameter of the j-th Gaussian component. μj is the mean, and σj is the standard deviation. K is the number of Gaussian components in the GMM. Ψ(x|μj, σj) is the probability density function of a single Gaussian distribution, and Ψ(x|μj, σj) can be expressed as(4)Ψx|μj,σj=12πσj2exp−x−μj22σj2.Gebru et al. [25] further introduced the concept of sample weights based on the GMM. It combines the sample weights and the GMM by treating the weight ω of sample x as ω times equivalent observations of x. Then, the probability density distribution p(x|Θ, ω) of the weighted GMM can be derived as(5)px|Θ,ω=∑j=1KφjΨx|μj,σjω.The weighted GMM can model the density distribution of vehicle trajectories on road cross sections. Sample valuex can be expressed as the position of a trajectory on the road cross section. ω is the estimated positioning accuracy of each trajectory segment. K can be expressed as the number of lanes. φj is equivalent to the ratio of lane traffic flow to roadway traffic flow. μj corresponds to the position of each lane centerline. σj is the dispersion of trajectories on each lane. σj is related to the width of a lane. According to urban road construction standards, the width of each lane on the same roadway should be equal. Thus, σj of every Gaussian distribution is the same in a weighted GMM, that is, σ1 = σ2 = ⋯ = σK = σ. We call the weighted GMM constrained by the same σ as the weighted constrained GMM (WCGMM). Lane-level road information can be obtained by solving the parameters of the model.The EM algorithm calculates the parameters of the WCGMM. The EM algorithm is widely used to solve the latent variable model. It can estimate the maximum likelihood probability, or posterior probability, of a latent variable model in an iterative manner. The maximum posterior probability method is used to estimate the parameters. To express model parameters in the iterative process of the EM algorithm, we represent model parameters Θ as (φj(m), μj(m), σ(m)), where m is the solution of the m-th iteration process. For the initial value of parameters in the first iteration, we set them as φ1(0) = φ2(0) = ⋯φK(0) = 1/K, and the setting of σ(0) can refer to the standard width of lanes. We set σ(0) to 1.75 meters and set the initially estimated position μj(0) by σ(0) and lanes number K.The above EM algorithm is divided into two steps: step E estimates the probability of each sample belonging to each Gaussian component. Step M updates the model parameters. We alternate the step E and step M iteratively to make the model gradually approach the maximum posterior probability. Among them, the calculation method of step E is(6)γijm=φjmΨxi|μjm,σ/ωim∑l=1KφlmΨxi|μlm,σ/ωim,where xi is the i-th sample value, ωi is the weight of xi, and γij(m) represents the probability that xi belongs to the j-th Gaussian component during the m-th iteration. Step M updates the parameters of the WCGMM according to the probabilities that each sample calculated in step E belongs to different Gaussian components. If the total number of samples is n, the calculation method is(7)φjm+1=∑i=1nγijmn,μjm+1=1∑i=1nωiγijm∑i=1nωiγijmxi,σm=1∑i=1nγijm∑i=1nωiγijmxi−μjm+12.When the number of lanes on a road cross section is known, the value of each unknown parameter can be calculated through the EM algorithm. Then the lane centerline and lane width can be estimated. Meanwhile, this model’s likelihood can be calculated using model parameters. The likelihood can be understood as the probability of the current trajectory state distribution under the conditions of the known number of lanes and model parameters. It can be expressed as equation (8). In the next section, we will use the log-likelihood of the model to extract the number of lanes.(8)LX|Θ,K=∏i=1npxi|Θ,ωi,K.


## 3.2.2. Extraction of Lane Counts on Continuous Road Cross Sections

The ratio of vehicle lane-changing behavior between adjacent road cross sections is related to the number of lanes. If the number of lanes increases or decreases, many vehicles will change lanes. When the traffic volume of each lane is approximately the same, the changes in lane counts can be estimated by the ratio of lane-changing vehicles to all vehicles on the road segment. As shown in Figure5, when the number of lanes changes from two to three, two of the three lanes on road cross section G is the continuation of the two lanes on road cross section F. The remaining one is the newly added lane. Vehicles on the newly-added lane must go through a lane change to reach the newly-added lane. Therefore, the number of lanes changes from F to G can be estimated by counting the ratio of vehicles that have caused lane-changing behavior.Figure 5
The relationship between lane-changing behavior and the lane counts.Under the premise that trajectory distribution on the road and the number of lane-changing vehicles are known, the lane counts estimation can be modeled by the hidden Markov model (HMM). HMM is a Markov process with hidden states and observations [26]. Each state has an observation probability for the possible observations. The transition probability defines the state-to-state transition. The hidden state sequence can be generated by maximizing the overall probability given a series of observations. HMM mainly includes five elements, namely two state sets and three probability matrices [27]:Hidden state H: the hidden state in HMM cannot be obtained by direct observation. These states satisfy the Markov property. Each hidden state is only related to its neighboring hidden states.Observation state O: A state that can be obtained by direct observation and is related to an implicit state in HMM.State transition matrixB: the matrix describes the transition probability between the hidden states in HMM. B = [bij]M×M, where bij = P(ht+1 = Hj|ht = Hi), 1 ≤ i, j ≤ M, and M is the number of hidden states. bij represents the probability that the hidden state is Hj at t + 1, and the hidden state is Hi at t.Observation state matrixC: this matrix describes the probability of the current observation state under the condition that the hidden state is known. C = [cj(k)]M×N, where cj(k) = P(ot = Ok|ht = Hj), 1 ≤ k ≤ N, N is the number of observation states. cj(k) represents the probability that the observed state is Ok, and the hidden state is Hj at time t.The initial state matrixη: η = (ηi), ηi = P(h1 = Hi), 1 ≤ i ≤ N. It represents the probability matrix of the hidden state at the initial time t = 1.The number of lanes at multiple road cross sections can be considered a Markov process. It means the number of lanes at each road cross section is only related to adjacent road cross sections. Therefore, the HMM model can be established by taking the number of lanes on multiple consecutive road cross sections as the hidden state, assuming that the number of lanes at multiple consecutive road cross sections isH = {h1, h2, …, hT}, where T is the number of road cross sections. The trajectory distribution can model the observation state O on each road cross section, namely O = {o1, o2, …, oT}. According to the fitting result of the WCGMM on the trajectory distribution, the observation state matrix C can be calculated. Each element cj(k) in C can be expressed as(9)cjk=lnLOk|Θ,Hj,where L(Ok|Θ, Hj) is the likelihood of the WCGMM under the condition that the number of lanes is Hj. It can be calculated by equation (8). The value of this probability is usually minimal because the probability is in the form of multiplication of multiple probabilities. Therefore, we use the log-likelihood to calculate the observation state. The maximum log-likelihood of all observation states is used for the min-max normalization to facilitate computer processing.The state transition matrixB can be defined according to the ratio of the lane-changing vehicle. Each element bij in B can be expressed as(10)bij=Pht+1=Hj|ht=Hi=exp−Hi−Hj−βt,t+1⋅maxHi,Hj2,where βt,t+1 is the ratio of lane-changing vehicles between the t and t + 1 road cross sections. The product of βt,t+1, and the maximum number of lanes on the adjacent road cross section is the number of changing lanes. According to the difference between hidden states Hi and Hj, the number of changing lanes can also be obtained. Therefore, the probability of lane counts on the current and previous road cross sections is Hj and Hi, which can be calculated according to the number of changing lanes. Taking into account that some vehicles may change lanes due to the need to overtake or turn even if there is no new lane, βt,t+1 is expressed as(11)βt,t+1=CGleft−CGrightCRtotal,where CGleft and CGright represent the number of vehicles changing lanes to the left and right, respectively. CRtotal represents the number of all vehicles between two adjacent road cross sections. βt,t+1 is calculated this way because the probability of vehicles changing to the left and right sides is considered equal when no additional lanes exist. Using the difference in the number of vehicles changing lanes to the left and right can avoid the influence of overtaking or turning.The number of lane-changing vehicles can be extracted according to the lane-change trajectory points identified in Section3.1. First, we count all lane-change trajectory points between two adjacent road cross sections. Then these points are classified into left and right categories according to the change in direction. Finally, the number of vehicles changing direction to the left or right is counted by the vehicle’s ID of trajectory points.The observed state probability can directly represent the initial state matrix. We take the maximum number of lanes as a parameter of the algorithm, and the candidate set of hidden state variables can be determined according to the maximum number of lanes. The solution to the hidden state in HMM is to find the number of lanes on each road cross section with the most significant overall probability. Generally, it can be solved by the Viterbi algorithm [28]. After using the Viterbi algorithm to find the number of lanes in each road cross section, the WCGMM corresponding to each road cross section can be determined. Then the lane information on a road cross section can be obtained using model parameters.


## 3.2.3. Extraction of Lane Centerlines

The HMM and the WCGMM can generate lane centerline nodes on road cross sections. Then, we need to construct lane centerlines by connecting these nodes on multiple consecutive road cross sections. To make the constructed lane centerlines as close to the actual lane centerlines as possible, we need to divide the road into as many cross sections as possible. These multiple road cross sections are set along the centerline of a road at a fixed length interval to extract the lane centerline nodes. We take the fixed-length interval of road cross sections as a parameter of the algorithm. Then, we can extract multiple-lane centerline nodes with more than two lanes on one road cross section. Besides, the number of centerline nodes on adjacent road cross sections may differ when lanes change. It is necessary to determine which two nodes on the adjacent road cross sections need to be connected. A method for connecting lane centerline nodes is proposed based on the minimum matching distance, which includes the following steps:Step 1: Index the lane centerline nodes. Sort the nodes on a cross section according to the distance between the node and the road’s centerline. Then number the nodes according to the sort order. As shown in Figure6, for the nodes on road cross section G, the closest node to the centerline is G1, followed by G2 and G3, until the n-th node is Gn.Step 2: Build a candidate match set. Since the number of lanes on two adjacent road cross sections may differ, we use the road cross section with fewer lanes as a reference. Then we match the nodes on the cross section with more lanes on the reference road cross section. If two adjacent road cross sections areF and G, then the number of lanes in F is m, the lane counts in G is n, and m < n. Therefore, the set of nodes in F is FNode = {F1, F2, …, Fm}, and the set of nodes in G is GNode = {G1, G2, …, Gn}. According to the node index in G, the candidate matching set for FNode is constructed. Each candidate matching set for FNode is {Gi, Gi+1, …, Gi+m−1}, with i from 1 to n + 1 − m. According to each candidate matching set, a matching pair can be constructed, that is, F1 matches Gi, F2 matches Gi+1, and Fm matches Gi+m−1.Step 3: Calculate the matching distance. For each candidate matching set, we calculate the distance of each matching pair in the matching set. Then we calculate the sum of all distances for each matching pair. The sum is the matching distance of the whole candidate matching set.Step 4: Construct the centerlines of lanes. The candidate matching set with the smallest matching distance is selected. We connect the corresponding nodes according to each matching pair, as shown by the solid red line in Figure7. For the unmatched node Gu on road cross section G, we find the closest matching node Gv on G. Then we connect Gu to the corresponding matching node of Gv on road cross section F, as shown by the red dashed line in Figure 7.Figure 6
Lane centerline node index.Figure 7
Lane centerline node connection.


## 4. Experiments

The experiments are described in the following sections.


### 4.1. Experimental Data Collection and Preprocessing

Mapillary is a street-level image data-sharing platform based on geospatial tags. Users can upload vehicle trajectory data with geographic location tags for individuals or teams. Through the service interface and development toolkit provided by Mapillary, users can download crowdsourced vehicle trajectory data on the platform. We found that the number of trajectories uploaded by users in the San Francisco area is relatively large, and the higher the road grade, the higher the trajectory coverage rate. In order to ensure that there are enough trajectories to cover the road area, we collect vehicle trajectories on motorway sections, including US 101, CA 1, I280, and I80. Figure8 shows the result of superimposing collected trajectory data on Google Satellite Maps. As can be seen from Figure 8, the research area contains complex road scenes such as curves, tunnels, and overpasses. The blue lines in Figure 8 are trajectory data. It contains 3,728 trajectories and 557,924 trajectory points. These trajectories are sampled at intervals ranging from 1 to 10 seconds. The average sampling interval is 2.36 seconds. The positioning errors of some trajectories exceed 100 meters. We treat these vehicle trajectories with significant positioning errors as noise data. Therefore, this data needs to be preprocessed before lane information extraction to eliminate the noise.Figure 8
Vehicle trajectory data in the study area.We download the road centerline data within the research area from the OSM website. The road centerlines are used to estimate the positioning error of each trajectory using the error calculation method proposed in Section3.2. We introduced the natural discontinuity method [29] to determine the positioning error threshold of noise. Trajectories with errors higher than the threshold are regarded as noisy. Figure 9 shows the vehicle trajectories after preprocessing on one of the road sections in the research area. Trajectories on the left and right sides of the road are distinguished. We use vehicle trajectories on each side to extract lane information, respectively. Table 1 shows the parameter setting of the proposed method. According to road construction standards, the maximum number of lanes on urban roads is set at 6. Therefore, the candidate hidden value in the HMM model is {1, 2, 3, 4, 5, 6}. The length of the interval between road cross sections is related to the algorithm efficiency and the smoothness of the extracted lane centerlines. The longer the interval, the faster the calculation speed, while the shorter the interval, the smoother the extracted lane centerline. We set the length interval to 20 meters considering the above two factors.Figure 9
Preprocessed vehicle trajectory data.Table 1
Parameters setting of the proposed method.
ParameterValueMax number of the lanes6Length interval of road cross sections20 meters


### 4.2. Extraction of Lane-Changing Trajectory Points

The extraction of lane-changing trajectory points is the first step in the proposed method. By observing the trajectory distribution on different roads, we found a specific correlation between the lane-changing behavior of vehicles and the change in the number of lanes. In order to verify the rationality of this assumption, we selected two road sections (road sections A and B in Figure10) in the study area to carry out experiments. The number of lanes on road section A remains the same, and the number of lanes on road section B changes from 4 to 5. The traffic volumes of the two road sections are similar.Figure 10
Extraction results of lane-changing trajectory points.The purple and pink points in Figure10 are the vehicle lane-changing trajectory points extracted by the method proposed in this paper. It can be seen that more vehicles have changed lanes on road B. The detection results were consistent with the visual results. We further count the number of detected lane-changing vehicles. As shown in Figure 11, it can be seen that more vehicles change lanes to the right in road section B. This is because some vehicles need to enter the new lane on the right. There are also more vehicles changing lanes to the right than to the left on road A. We think this may be caused by the driving habits of drivers. The driving habits of drivers can be further studied quantitatively. However, it is not significant compared with the difference caused by adding lanes. Thus, we did not take this factor into account in our method.Figure 11
Statistical results of lane-changing vehicles.


### 4.3. Construction of Lane Centerlines

Accurately fitting the trajectory distribution on the road cross section is the key to extracting the lane centerline. Based on the existing CGMM, we propose a weighted constrained Gaussian mixture model combined with the trajectory positioning error and verify the method’s effectiveness through the trajectory data on road A in Figure10. Figure 12 shows the trajectory distribution fitting results of the WCGMM method under the assumption of different numbers of lanes. Unlike the original Gaussian mixture model, the weighted Gaussian mixture model is related to the error of each sample. Thus, the fitted distribution of the Gaussian mixture model is not a smooth curve. Figure 13 is the log-likelihood for each subgraph in Figure 12. It can be seen that the largest log-likelihood is under the condition of 4 lanes, consistent with the results observed in Figure 10.Figure 12
Fitting results of trajectory distribution on road cross-section based on WCGMM: (a) condition of one lane, (b) condition of two lanes, (c) condition of three lanes, (d) condition of four lanes, (e) condition of five lanes, and (f) condition of six lanes.
(a)(b)(c)(d)(e)(f)Figure 13
The log-likelihood of trajectory distribution under different numbers of lanes.An accurate estimation of the number of lanes is the basis of lane centerline extraction. In order to accurately estimate the number of lanes from the trajectory data, our method has made two improvements. First, a weighted-based constrained Gaussian mixture model is proposed. Based on the original constrained Gaussian mixture model, the influence of trajectory positioning errors is considered, and the weight of high-precision trajectory data is increased while the impact of low-precision trajectory data errors is reduced on model fitting accuracy. Then, a hidden Markov model is used to model the correlation between vehicle lane-changing behavior and lane number changes to improve the consistency of lane number estimates on adjacent road cross sections.Figure14 shows the number of lanes extracted using the trajectory data in Figure 9. The actual lane number of the road is obtained by manually interpreting the Google Satellite Map at each road cross section. Figure 14(a) is an improved method that only adds a weighted constrained Gaussian mixture model. Figure 14(b) is the extraction result of the number of lanes obtained using a weighted constrained Gaussian mixture model and a hidden Markov model to fit the distribution of road transverse and longitudinal trajectories. It can be found that the continuity of the number of lanes on the road is more robust when both improvement methods are used at the same time, compared with only using the weighted constrained Gaussian mixture model.Figure 14
The number of actual lanes and the number of extracted lanes on multiple consecutive road cross sections: (a) estimated results based on the WCGMM; (b) estimated results based on the WCGMM and HMM.
(a)(b)In order to further verify the effectiveness of the method, we use all the trajectory data collected in the study area to construct a lane-level road map, as shown in Figure15. In order to show the detailed information extracted from the lane centerline more clearly, we selected three representative areas, a, b, and c, in Figure 15. Area a is the scene where vehicles pass through the tunnel; area b is a curve; and area c is a viaduct where multiple roads converge. Figure 16 is the result of lane centerline extraction in three scenarios. Figure 16(a) superimposes the extracted lane centerlines and experimental trajectory data, and Figure 16(b) superimposes the extracted lane centerlines and reference lane centerlines. The centerline of the reference lane is manually compared with Google Maps’ vectorization. It should be noted that due to the positioning error of Google Maps itself, there will also be errors in the centerline of the reference lane generated by the manual vectorization of Google Maps. We consider the reference lane centerline error acceptable compared to the lane centerline extracted by trajectory. Because many lane-level road maps also use Google Maps as the primary data source.Figure 15
Lane-level road map generation results based on the proposed method.Figure 16
Lane-level road map generation results based on the proposed method within the three selected areas: (a) the extracted lane centerlines and experimental trajectory data; (b) the extracted lane centerlines and reference lane centerlines.
(a)(b)Figure16 shows that the lane centerline extraction results in area b are relatively more accurate, the lane width extracted in area a is wider than the actual width, and the number of lanes and lane centerline positions of some roads in area c are incorrectly extracted. Comparing the extraction results of the three regions, we found that two reasons may reduce the extraction accuracy of lane information. The first reason is the trajectory error. Although the WCGMM model considers the influence of the trajectory error, it cannot eliminate the trajectory positioning error. When the error is too large and the number of samples is insufficient, even if the number of lanes can be estimated correctly, there will still be a significant deviation in the position of the fitted centerline. The second reason is insufficient trajectory coverage. When the trajectory distribution on a specific lane is sparse or even has no trajectory, the uncertainty of the extracted lane information will increase. In addition, this paper’s method only applies to the extraction of lane information from road segments. For the lane information of road intersections, the steering behavior of different vehicle trajectories is used to further extract the routing information of the intersection after extracting the lane information on road segments.


### 4.4. Quantitative Evaluation

Existing methods for extracting lane information using vehicle trajectories mainly include KDE (kernel density estimation), proposed by Uduwaragoda et al. [12], and CGMM (constrained Gaussian mixture model) proposed by Chen and Krumm [13]. Among them, the CGMM method uses constraint conditions such as trajectory coverage width and lane width to fit a Gaussian mixture distribution on the trajectories of a road cross section. Then, it extracts lane information according to the parameters of the fitted Gaussian mixture model. The KDE method estimates the trajectory density distribution of vehicle trajectories in the X-axis and Y-axis through kernel density. Then it determines the position of lane centerlines according to the peak points of the trajectory density distribution. The proposed method combines the constrained Gaussian mixture model with lane-changing features of trajectories. The method uses a weighted constrained Gaussian mixture model and a hidden Markov model to estimate the number of lanes and extract lane centerlines.The results of the lane count extraction experiment with different methods are shown in Table2. They are obtained by calculating the ratio of correctly extracted road cross sections to total road cross sections. These results show that the accuracy of lane count recognition based on GMM is better than kernel density estimation. Compared with CGMM and KDE, the proposed method uses trajectory information between adjacent road cross sections and lane-changing features. It can improve the accuracy of lane count extraction. In addition, compared with only using the WCGMM model, combining HMM and WCGMM can further improve the algorithm’s accuracy.Table 2
Accuracy comparison of lane counts extraction
Lane counts extraction methodsAccuracy (%)KDE [12]65.3CGMM [13]75.5Proposed WCGMM76.8Proposed WCGMM and HMM78.6The comparative analysis of the lane centerline extraction experiment needs to use the actual lane centerline as a reference. Google satellite map is used as a reference. The reference lane centerlines are obtained by manually vectorizing lane centerlines in the research area. The extraction error can be estimated according to the distance between the extracted and reference centerline nodes. The average, minimum, maximum, and standard deviation of the distance between each node are used as the index of extraction accuracy. Table3 shows the evaluation results of each method. It can be found that the kernel density estimation method has lower accuracy than GMM because the former needs to select an appropriate kernel density radius. If the trajectory positioning accuracy is low, it is not easy to estimate the accurate density distribution of vehicle trajectories on the road. The Gaussian mixture model can achieve more accurate results by adding the constraints of prior knowledge. The proposed method takes trajectory positioning accuracy as the weight in the constrained Gaussian mixture model. It can further improve the accuracy of lane centerline extraction. Thus, the average error of the proposed method is minor. Using both the WCGMM and the HMM model can reduce the error variance compared to only using the WCGMM model. It is because the HMM uses the vehicle’s lane-changing behavior to model the longitudinal trajectory distribution of the road so that the lane information on different road cross sections has a better consistency.Table 3
Comparative analysis of the position accuracy of lane centerlines.
CGMMKDEProposed WCGMMProposed WCGMM and HMMAverage (m)4.336.523.823.15Minimum (m)0.010.170.050.01Maximum (m)8.2512.119.548.32Standard deviation (m)0.942.570.890.55


## 4.1. Experimental Data Collection and Preprocessing

Mapillary is a street-level image data-sharing platform based on geospatial tags. Users can upload vehicle trajectory data with geographic location tags for individuals or teams. Through the service interface and development toolkit provided by Mapillary, users can download crowdsourced vehicle trajectory data on the platform. We found that the number of trajectories uploaded by users in the San Francisco area is relatively large, and the higher the road grade, the higher the trajectory coverage rate. In order to ensure that there are enough trajectories to cover the road area, we collect vehicle trajectories on motorway sections, including US 101, CA 1, I280, and I80. Figure8 shows the result of superimposing collected trajectory data on Google Satellite Maps. As can be seen from Figure 8, the research area contains complex road scenes such as curves, tunnels, and overpasses. The blue lines in Figure 8 are trajectory data. It contains 3,728 trajectories and 557,924 trajectory points. These trajectories are sampled at intervals ranging from 1 to 10 seconds. The average sampling interval is 2.36 seconds. The positioning errors of some trajectories exceed 100 meters. We treat these vehicle trajectories with significant positioning errors as noise data. Therefore, this data needs to be preprocessed before lane information extraction to eliminate the noise.Figure 8
Vehicle trajectory data in the study area.We download the road centerline data within the research area from the OSM website. The road centerlines are used to estimate the positioning error of each trajectory using the error calculation method proposed in Section3.2. We introduced the natural discontinuity method [29] to determine the positioning error threshold of noise. Trajectories with errors higher than the threshold are regarded as noisy. Figure 9 shows the vehicle trajectories after preprocessing on one of the road sections in the research area. Trajectories on the left and right sides of the road are distinguished. We use vehicle trajectories on each side to extract lane information, respectively. Table 1 shows the parameter setting of the proposed method. According to road construction standards, the maximum number of lanes on urban roads is set at 6. Therefore, the candidate hidden value in the HMM model is {1, 2, 3, 4, 5, 6}. The length of the interval between road cross sections is related to the algorithm efficiency and the smoothness of the extracted lane centerlines. The longer the interval, the faster the calculation speed, while the shorter the interval, the smoother the extracted lane centerline. We set the length interval to 20 meters considering the above two factors.Figure 9
Preprocessed vehicle trajectory data.Table 1
Parameters setting of the proposed method.
ParameterValueMax number of the lanes6Length interval of road cross sections20 meters


## 4.2. Extraction of Lane-Changing Trajectory Points

The extraction of lane-changing trajectory points is the first step in the proposed method. By observing the trajectory distribution on different roads, we found a specific correlation between the lane-changing behavior of vehicles and the change in the number of lanes. In order to verify the rationality of this assumption, we selected two road sections (road sections A and B in Figure10) in the study area to carry out experiments. The number of lanes on road section A remains the same, and the number of lanes on road section B changes from 4 to 5. The traffic volumes of the two road sections are similar.Figure 10
Extraction results of lane-changing trajectory points.The purple and pink points in Figure10 are the vehicle lane-changing trajectory points extracted by the method proposed in this paper. It can be seen that more vehicles have changed lanes on road B. The detection results were consistent with the visual results. We further count the number of detected lane-changing vehicles. As shown in Figure 11, it can be seen that more vehicles change lanes to the right in road section B. This is because some vehicles need to enter the new lane on the right. There are also more vehicles changing lanes to the right than to the left on road A. We think this may be caused by the driving habits of drivers. The driving habits of drivers can be further studied quantitatively. However, it is not significant compared with the difference caused by adding lanes. Thus, we did not take this factor into account in our method.Figure 11
Statistical results of lane-changing vehicles.


## 4.3. Construction of Lane Centerlines

Accurately fitting the trajectory distribution on the road cross section is the key to extracting the lane centerline. Based on the existing CGMM, we propose a weighted constrained Gaussian mixture model combined with the trajectory positioning error and verify the method’s effectiveness through the trajectory data on road A in Figure10. Figure 12 shows the trajectory distribution fitting results of the WCGMM method under the assumption of different numbers of lanes. Unlike the original Gaussian mixture model, the weighted Gaussian mixture model is related to the error of each sample. Thus, the fitted distribution of the Gaussian mixture model is not a smooth curve. Figure 13 is the log-likelihood for each subgraph in Figure 12. It can be seen that the largest log-likelihood is under the condition of 4 lanes, consistent with the results observed in Figure 10.Figure 12
Fitting results of trajectory distribution on road cross-section based on WCGMM: (a) condition of one lane, (b) condition of two lanes, (c) condition of three lanes, (d) condition of four lanes, (e) condition of five lanes, and (f) condition of six lanes.
(a)(b)(c)(d)(e)(f)Figure 13
The log-likelihood of trajectory distribution under different numbers of lanes.An accurate estimation of the number of lanes is the basis of lane centerline extraction. In order to accurately estimate the number of lanes from the trajectory data, our method has made two improvements. First, a weighted-based constrained Gaussian mixture model is proposed. Based on the original constrained Gaussian mixture model, the influence of trajectory positioning errors is considered, and the weight of high-precision trajectory data is increased while the impact of low-precision trajectory data errors is reduced on model fitting accuracy. Then, a hidden Markov model is used to model the correlation between vehicle lane-changing behavior and lane number changes to improve the consistency of lane number estimates on adjacent road cross sections.Figure14 shows the number of lanes extracted using the trajectory data in Figure 9. The actual lane number of the road is obtained by manually interpreting the Google Satellite Map at each road cross section. Figure 14(a) is an improved method that only adds a weighted constrained Gaussian mixture model. Figure 14(b) is the extraction result of the number of lanes obtained using a weighted constrained Gaussian mixture model and a hidden Markov model to fit the distribution of road transverse and longitudinal trajectories. It can be found that the continuity of the number of lanes on the road is more robust when both improvement methods are used at the same time, compared with only using the weighted constrained Gaussian mixture model.Figure 14
The number of actual lanes and the number of extracted lanes on multiple consecutive road cross sections: (a) estimated results based on the WCGMM; (b) estimated results based on the WCGMM and HMM.
(a)(b)In order to further verify the effectiveness of the method, we use all the trajectory data collected in the study area to construct a lane-level road map, as shown in Figure15. In order to show the detailed information extracted from the lane centerline more clearly, we selected three representative areas, a, b, and c, in Figure 15. Area a is the scene where vehicles pass through the tunnel; area b is a curve; and area c is a viaduct where multiple roads converge. Figure 16 is the result of lane centerline extraction in three scenarios. Figure 16(a) superimposes the extracted lane centerlines and experimental trajectory data, and Figure 16(b) superimposes the extracted lane centerlines and reference lane centerlines. The centerline of the reference lane is manually compared with Google Maps’ vectorization. It should be noted that due to the positioning error of Google Maps itself, there will also be errors in the centerline of the reference lane generated by the manual vectorization of Google Maps. We consider the reference lane centerline error acceptable compared to the lane centerline extracted by trajectory. Because many lane-level road maps also use Google Maps as the primary data source.Figure 15
Lane-level road map generation results based on the proposed method.Figure 16
Lane-level road map generation results based on the proposed method within the three selected areas: (a) the extracted lane centerlines and experimental trajectory data; (b) the extracted lane centerlines and reference lane centerlines.
(a)(b)Figure16 shows that the lane centerline extraction results in area b are relatively more accurate, the lane width extracted in area a is wider than the actual width, and the number of lanes and lane centerline positions of some roads in area c are incorrectly extracted. Comparing the extraction results of the three regions, we found that two reasons may reduce the extraction accuracy of lane information. The first reason is the trajectory error. Although the WCGMM model considers the influence of the trajectory error, it cannot eliminate the trajectory positioning error. When the error is too large and the number of samples is insufficient, even if the number of lanes can be estimated correctly, there will still be a significant deviation in the position of the fitted centerline. The second reason is insufficient trajectory coverage. When the trajectory distribution on a specific lane is sparse or even has no trajectory, the uncertainty of the extracted lane information will increase. In addition, this paper’s method only applies to the extraction of lane information from road segments. For the lane information of road intersections, the steering behavior of different vehicle trajectories is used to further extract the routing information of the intersection after extracting the lane information on road segments.


## 4.4. Quantitative Evaluation

Existing methods for extracting lane information using vehicle trajectories mainly include KDE (kernel density estimation), proposed by Uduwaragoda et al. [12], and CGMM (constrained Gaussian mixture model) proposed by Chen and Krumm [13]. Among them, the CGMM method uses constraint conditions such as trajectory coverage width and lane width to fit a Gaussian mixture distribution on the trajectories of a road cross section. Then, it extracts lane information according to the parameters of the fitted Gaussian mixture model. The KDE method estimates the trajectory density distribution of vehicle trajectories in the X-axis and Y-axis through kernel density. Then it determines the position of lane centerlines according to the peak points of the trajectory density distribution. The proposed method combines the constrained Gaussian mixture model with lane-changing features of trajectories. The method uses a weighted constrained Gaussian mixture model and a hidden Markov model to estimate the number of lanes and extract lane centerlines.The results of the lane count extraction experiment with different methods are shown in Table2. They are obtained by calculating the ratio of correctly extracted road cross sections to total road cross sections. These results show that the accuracy of lane count recognition based on GMM is better than kernel density estimation. Compared with CGMM and KDE, the proposed method uses trajectory information between adjacent road cross sections and lane-changing features. It can improve the accuracy of lane count extraction. In addition, compared with only using the WCGMM model, combining HMM and WCGMM can further improve the algorithm’s accuracy.Table 2
Accuracy comparison of lane counts extraction
Lane counts extraction methodsAccuracy (%)KDE [12]65.3CGMM [13]75.5Proposed WCGMM76.8Proposed WCGMM and HMM78.6The comparative analysis of the lane centerline extraction experiment needs to use the actual lane centerline as a reference. Google satellite map is used as a reference. The reference lane centerlines are obtained by manually vectorizing lane centerlines in the research area. The extraction error can be estimated according to the distance between the extracted and reference centerline nodes. The average, minimum, maximum, and standard deviation of the distance between each node are used as the index of extraction accuracy. Table3 shows the evaluation results of each method. It can be found that the kernel density estimation method has lower accuracy than GMM because the former needs to select an appropriate kernel density radius. If the trajectory positioning accuracy is low, it is not easy to estimate the accurate density distribution of vehicle trajectories on the road. The Gaussian mixture model can achieve more accurate results by adding the constraints of prior knowledge. The proposed method takes trajectory positioning accuracy as the weight in the constrained Gaussian mixture model. It can further improve the accuracy of lane centerline extraction. Thus, the average error of the proposed method is minor. Using both the WCGMM and the HMM model can reduce the error variance compared to only using the WCGMM model. It is because the HMM uses the vehicle’s lane-changing behavior to model the longitudinal trajectory distribution of the road so that the lane information on different road cross sections has a better consistency.Table 3
Comparative analysis of the position accuracy of lane centerlines.
CGMMKDEProposed WCGMMProposed WCGMM and HMMAverage (m)4.336.523.823.15Minimum (m)0.010.170.050.01Maximum (m)8.2512.119.548.32Standard deviation (m)0.942.570.890.55


## 5. Conclusions

This article studies the problem of using crowdsourced vehicle trajectories to extract lane centerlines. A high-precision lane centerline extraction method is proposed based on the weighted, constrained Gaussian mixture model and the hidden Markov model. The proposed method first introduces the Frenet coordinate system based on road centerlines. Then it fits the vehicle trajectory in the Frenet coordinate system. Based on the fitted trajectory, it extracts critical features that best distinguish between lane-changing and nonlane-changing points. Then, vehicle trajectories with positioning errors are used to model the weighted constrained Gaussian mixture model. The hidden Markov model is constructed according to the lane-changing trajectory points to estimate the number of lanes in the WCGMM. Finally, lane centerline nodes are extracted from the parameters of the WCGMM. Lane centerlines are constructed from these nodes. Vehicle trajectories in San Francisco collected from Mapillary are used to verify and analyze the proposed method. Experimental results show that our method’s lane count extraction accuracy reaches 78.6% and the average positioning error of extracted lane centerlines is 3.15 m. Compared with existing methods, the proposed method takes the trajectory positioning accuracy as a weight, which can effectively improve the accuracy of lane counts and lane centerline extraction. However, considering the practical application requirements, the proposed method still needs to improve lane centerline extraction’s position accuracy and robustness. Besides, this method does not consider lane distribution at road intersections. Our future work will focus on lane information extraction in a complex road network with road intersections.



---

*Source: 6040122-2022-12-21.xml*