\subsection{Complementary Data}

With the exception of speed and aggregated traffic volume counts, vehicle trajectories offer little insight without context. Complementary data about the scene is collected and added in order to perform further analysis. This data includes a wide variety of design geometry and environment attributes characterizing the factors under study.

\subsubsection{Analysis Area}

The analysis area is a bounding polygon which confines analysis to a particular region of the scene. This serves to i) reject regions of the image with unsatisfactory feature tracking (particularly at the edges of camera space), and ii) confine analysis to a particular region. An example of the analysis area is demonstrated in Figure~\ref{fig:complex-network}.
%The analysis area differs from a mask used during feature tracking, which instructs the computer vision to ignore certain portions of the image. Feature tracking which uses a mask is still prone to "warm-up" tracking errors at the edge of the mask.

\subsubsection{Alignments}
\label{alignments}

Trajectory clustering is the first step in behavioural analysis. Trajectory clustering is an abstract representation of movements along prototypical paths through a scene, called alignments. This is the foundation for relating spatial position of trajectories with elements of road geometry and, in particular, the position of moving objects in relation to traffic lanes, bike paths, and side walks.

Many approaches to trajectory clustering have been explored. While some methods are supervised \cite{Schreck_2008}, many more are unsupervised (e.g. k-means \cite{MacQueen_1967} or hidden Markov models \cite{Rodr_guez_Serrano_2012}). Manual trajectory clustering is labour intensive and may be a source of bias, but it allows for tight control of scene description and analysis oversight. Unsupervised clustering is systematic but naive, as this form of clustering can only make use of trajectory data to infer spatial relationship. Manual clustering along a series of splines, called alignments, is chosen for its simple implementation and tight control over interpretation. A hybrid approach, which automatically refines the spatial positioning of manually defined alignments through traditional unsupervised clustering approaches, is considered for future improvements \cite{morris08survey, Schreck_2008}.

The alignment is represented as a simple series of points with a beginning and an end, in the same direction of travel as the majority of movements along this path. This process introduces a new coordinate system which maps a position of a moving object in Cartesian space to a position in curvilinear space:

\begin{equation} \label{eqn:coordinate-transform} (x,y)\to(l,s,\gamma). \end{equation}

where a point located at $(x,y)$ in Cartesian space is snapped orthogonally to the nearest position on the nearest alignment $l$, and is represented by the curvilinear distance $s$ along this alignment from its beginning and the offset $\gamma$ (positive to the right of the vector), orthogonal to this alignment, measuring the distance between the original point and its position snapped to the alignment. A second pass may be performed over a moving window in less than the time users take to perform real lane changes to correct any localized lane "jumping" errors which frequently appear near converging or diverging alignments. These coordinates are useful for studying following behaviour, lane changes, and lane deflection.

\subsubsection{Network Topology}

Once trajectories are clustered, a network topology is constructed in order to be able to intelligently propagate future possible positions of moving objects through the network. In simple networks (i.e. two alignments), these movements are implicitly defined simply by observing lane change ratios, but in more complex networks, such as the network shown in Figure~\ref{fig:complex-network}, movements may involve multiple lane changes and therefore may require a more generalized approach. A recursive tree model is employed.

Alignment extremities are linked to other nearby alignments, creating diverging or converging branches, as are momentarily adjacent alignments. In addition, alignments which run parallel over a distance of more than 15 metres are instead grouped into corridors over which lane changes may occur freely. This creates a series of links and nodes with implicit direction which can be searched to determine all possible future positions of a moving object inside this network. This serves to reduce processing times of spatial relationship calculations between objects (triage) and provides more intelligent interpretation of spatial relationships.

\subsubsection{Geometric data/inventory}

Finally, a traditional inventory of contextual factors that may be related to the behaviours under study needs to be constructed and associated with each site. These typically include:
\begin{itemize}
\item \textbf{Geometric characteristics} including lane width, curvature, approach angles, and number of lanes, presence of slip lanes and/or lane configuration;
\item Presence of \textbf{horizontal and vertical signalization}: if proper placement is under evaluation, location may be recorded, or a typology of signage quality may be used instead;
\item \textbf{Pedestrian facilities} such as crosswalks, pedestrian refuges, etc.;
\item \textbf{Built environment}: school zones, land usage, clearance;
\item \textbf{Upstream/downstream distances to features} such as intersections, speed limit changes, rail-road crossings, etc.
\end{itemize}