# Modalflow: Cross-Origin Flow Data Visualization for Urban Mobility
## 4 Materials and Methods
### Data  
Our cross-origin datasets comprise trips in Santiago, the capital of Chile, a city with almost 8 million inhabitants in 35 administrative units denoted municipalities within its urban area, further subdivided into 735 traffic analysis zones. We define a flow as a unique origin-destination pair within a certain period (a partition of time), which has a magnitude (number of trips observed or predicted from origin to destination for the corresponding period) and a modal partition (the proportion of the magnitude corresponding to each mode of transport). Understood as a network where nodes are georeferenced objects, a flow is a weighted directed link with a modal partition uniquely defined by an origin-destination-period tuple. We also calculate a distance feature for each flow, as the linear geographical distance between origin and destination. _Travel Survey._ The main source of travel demand and characteristics information for transportation purposes is the Santiago Travel Survey (known as \"Encuesta Origen-Destino\" in Spanish, abbreviated EOD), which is held every ten years by the Chilean Transport Planning Secretary (SECTRA). In its last version from 2012, after surveying 100K inhabitants, the results showed that, in a typical working day, the transportation system has over 18 million trips, where walking is the most used mode of transport (34%), followed by public transport (26%), and private cars (26%) [41]. Arguably, most of the analysis of the travel survey focuses on the origin and destinations of trips, as well as their attributes, such as mode of transportation and travel distance. Given the sample size of the survey, only flows between municipalities are considered to be representative. Note that the traffic analysis zones of the city are defined by this survey. _Mobile Phone Network Data._ As input data for Modalflow, here we work with a dataset of inferred commuting trips from mobile phone network data. Specifically, we use Extended Data Detail Records (XDR), which is a type of passive data that are used by telecommunication companies for billing Internet usage from mobile phones [4]. The dataset used in this paper was provided by the telecommunications company Telefonica Movistar, which had a market share of 30% in April 2017. The dataset contains trips during April 2017 for approximately 600K devices, which were extracted while using a previously published method [42]. The trip distribution inferred from this dataset has been validated with experts and through comparison with a travel survey, which implied that the market share covered by the dataset is enough to measure mobility patterns in Santiago [39]. These trips include a prediction of the several available modes in the Santiago transportation network, including bus, subway (metro), cars, and pedestrian trips. The prediction of mode of transportation for flows was made while using a variation of the model published in Ref. [42], aiming at solving a limitation of the original method, namely, working with morning commuting trips for individual devices. We have updated the model to estimate modal partitions in flows between areas of the city at several periods of the day. The updated model consists of solving the following optimization problem:  
\[\min_{A,B}\|W-(L\odot A)\times B\|_{F}^{2},\]  
where:  
* \(W\) is a waypoint matrix, where every column represents a directed flow between two areas of the city, and every rows represents a tower. Thus, each cell \(w_{ij}\) contains the number of times that tower \(i\) appears in the trajectories in flow \(j\). * \(A\) and \(B\) are positive low-rank matrices that express the associations between \(k\) latent dimensions and each tower (\(A\)) and flow (\(B\)). * \(L\) is a \(k\)-rank labeling matrix where \(l_{ij}\) is 1 if tower \(i\) is associated to mode of transportation \(j\), 0 otherwise.