README
======

Dataset title:
Dataset of origin and destination pairs in street networks, for the evaluation of the Earth Mover's Distance as a metric of alignment.

Creators:
Arvid Krantz-Horned, Kai-Florian Richter, Zoe Falomir

Responsible organization:
Umeå University, Department of Computing Science

Acknowledgements:
This dataset and research was produced with the help of resources and support from the High
Performance Computing Center North (HPC2N) at Umeå University. (https://www.hpc2n.umu.se/)

See the Researchdata.se catalogue entry for this dataset for complete metadata, including the dataset description, recommended citation, contact information, and information about how to obtain the dataset. 

Description: This dataset contains 77,293 Origin and Destination pairs (OD-pair) that have been sampled from five locations in 100 different cities to evaluate the Earth Mover's Distance (EMD) between circular probability distributions as a metric of alignment. Where a higher EMD is indicative of a higher degree of misalignment between the orientations. The dataset was used to test whether a higher EMD is predictive of longer and more complex routes, and compare it to other predictors including properties of the street network that earlier research have identified as sources of route complexity.

Procedure:
The procedure is as follows, beginning with a list of 100 cities used in earlier research.
- In every city five origins are selected randomly within a bounding box using the city center as the center.
- The drivable and publicly accessible street network around each origin is downloaded and represented as a graph.
- Around each origin up to 180 destinations within 4750 to 5250 meters from the origin are selected in a circular fashion.
- The origin and destinations surrounding it are used to create origin-destination pairs (OD-pairs) 
- Data is gathered for every OD-pair, including information about the shortest route from the origin to the destination and information about the street network surrounding the OD-pair

License: The dataset is created with data provided by OpenStreetMap under the Open Database License (ODbL 1.0) (https://www.openstreetmap.org/copyright)

Dataset organization
--------------------

odpair_city_sample_nodes.csv:
- the set of origins selected across 100 different cities used as a basis for sampling OD-pairs.

odpair_data.csv
- the dataset of OD-pairs used to analyze alignment as indicated by the computed EMD as a predictor of more complex and longer routes.



Datafile descriptions
----------------------

------ odpair_city_sample_nodes.csv - origin locations used to sample OD-pairs.
- Columns separated by a comma
- Decimals formatted with a period

This file has information about the location of the nodes that were used as a basis for creating 500 graphs that were subsequently used to create the dataset of OD-pairs. Each location is used to define the center of a bounding box with sides that are 10km long. The street network contained within this bounding box is then downloaded and processed using the OSMNx package (v.2.0.1) to create a multi-directed graph which is used a basis for further analysis.
#### 1. id [integer]
The row index, beginning at 0.

#### 2. city_name_en [string]
The name of the city in english.

#### 3. country_name [string]
The name of the country in the language of the country.

#### 4. country_name_en [string]
The name of the country in english.

#### 5. region [string]
The region the city is located in. Possible regions are: US/Canada, Middle East/Africa, Latin America, Europe, Asia/Oceania

#### 6. network_type [string]
Passed as an argument to the graph_from_bbox() function to specify which filter to use when downloading data from OpenStreetMap via Overpass.
https://osmnx.readthedocs.io/en/stable/user-reference.html#osmnx.graph.graph_from_bbox

Below is the filter passed to the Overpass API.

```python

filters["drive"] = (
	f'["highway"]["area"!~"yes"]["access"!~"private"]'
	f'["highway"!~"abandoned|bridleway|bus_guideway|construction|corridor|cycleway|elevator|'
	f'"escalator|footway|no|path|pedestrian|planned|platform|proposed|raceway|razed|service|"'
	f'["motor_vehicle"!~"no"]["motorcar"!~"no"]'
	f'["service"!~"alley|driveway|emergency_access|parking|parking_aisle|private"]'
)

```

For more information about the Overpass query language check out:
<https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL>

#### 7. node_id [integer]
Unique OpenStreetMap id of the node. See <https://wiki.openstreetmap.org/wiki/Node>

#### 8. node_latlon [tuple of floats, (latitude, longitude)]
The Latitude and Longitude of the node, using the WGS84 / EPSG:4326 coordinate reference system.
Encapsulated as a string: "(lat,lon)".


------ odpair_data.csv
- Columns separated by a semicolon.
- Decimals formatted with a period.

The odpair dataset contains roughly 180 nodes distributed in a circle with a 5km radius around each of the 500 origins.This file contains 77,293 rows, with each row containing information about an OD-pair along with the shortest route from the origin to the destination the street network surrounding the OD-pair. 

#### 1. id [integer]
The row index, beginning at 1.

#### 2. city_name [string]
Name of the city that the OD-pair is in, in english.

#### 3. origin_node [integer]
Unique OpenStreetMap id of the origin node in the OD-pair. See <https://wiki.openstreetmap.org/wiki/Node>

#### 4. origin_point [(latitude,longitude)]
The Latitude and Longitude of the origin node, using the WGS84 / EPSG:4326 coordinate reference system.
Encapsulated as a string: "(lat,lon)".

#### 5. destination_node [int]
Unique OpenStreetMap id of the destination node in the OD-pair. See <https://wiki.openstreetmap.org/wiki/Node>

#### 6. destination_point [(latitude,longitude)]
The Latitude and Longitude of the origin node, using the WGS84 / EPSG:4326 coordinate reference system.
Encapsulated as a string: "(lat,lon)".

#### 7. od_distance [float, meters]
The straight line distance between the origin and destination nodes in meters. Calculated using the haversine formula using the WGS84 coordinates of the origin and destination, and then converted to meters by multiplying the radian with the Earth's radius in meters.

#### 8. bearings_dist_env_undirected_dist [list of integers]
A list of 36 integers, represeting the distribution of street orientations in the street network surrounding the OD-pair across 36 bins. Where each integer is the count of street bearings within a 10 degree interval, with the center of the first interval being North (a compass bearing of 0).
Here, a street is an edge connecting two intersections (u,v), and every street is treated as having two antipodal bearings, the compass bearings from u to v, and from v to u. 

#### 9. bearing_dist_prop_environment_orientation_entropy [float, nats]
The shannon entropy of the of the distribution of street orientations. Calculated using the formula: H = -sum(p_i * ln(p_i)) where p_i is the probability of a street bearing being in a 10 degree interval.


#### 10. grid_likeness [float, 0-1]
Entropy rescaled to represent how grid-like or orderly a street network is. Where 1 is a perfectly grid-like street orientation distribution and 0 is a perfectly uniform street orientation distribution. 
Following the procedure in:
>Boeing, G. (2019). Urban spatial order: Street network orientation, configuration, and entropy. Applied Network Science, 4(1), 67. https://doi.org/10.1007/s41109-019-0189-1"


#### 11. icd (Inter-Connection Density) [float]
The average number of streets per intersection in the street network surrounding the OD-pair.


#### 12. intersection_density [float]
The number of intersections per square kilometer in the street network surrounding the OD-pair.

#### 13. shortest_identifier [string, city_name-edgeweight-origin_node-destination_node]
A string formatted as city_name-edgeweight-origin_node-destination_node, where edgeweight is the weight of the edge used to calculate the shortest route.

#### 14. shortest_length [float, meters]
The length of the shortest route in meters.

#### 15. shortest_n_nodes [integer]
The number of intersections that the shortest route passes. As the edges and nodes in the underlying graph has been been simplified to have each node represent an intersection and each edge represent a street, the number of nodes is equal to the number of intersections.

#### 16. shortest_turn_types [list of strings]
A stringified list of strings, where each string represents the type of turn at each intersection that the shortest route passes through. The type of turns follow the scheme described in Duckham and Kulik (2003) referenced above.
For example: "['t_turn', 'N_way_straight','2_way_turn']" means that the shortest route involves a turn a T-intersection, then going straight at an intersection with N>2 number of branches, then turning at an intersection with exactly two branches.

#### 17. shortest_complexity [integer]
The complexity of the route computed using the algorithm and costs described in:
>Duckham and Kuliks Duckham, M., & Kulik, L. (2003). ‘Simplest’ Paths: Automated Route Selection for Navigation. In W. Kuhn, M. F. Worboys, & S. Timpf (Eds.), Spatial Information Theory. Foundations of Geographic Information Science (Vol. 2825, pp. 169–185). Springer Berlin Heidelberg. https://doi.org/10.1007/978-3-540-39923-0_12"

Route complexity is attributed to the number of intersections and the type of decision at each intersection. A cost in terms of added complexity is assigned to the outgoing edge of every edge-pair based on the type of turn made at the intersection between them. The complexity of following a route is then estimated as the cumulative cost of traveling across all edge-pairs from the origin to the destination. As an example, a turn at an intersection with more than two outgoing streets will add a complexity of (5+deg(v)) to the route, but a turn when entering a T-intersection, where the choice is between turning left or right, has a static cost of 6.


#### 18. bearings_dist_od_undirected_dist_perp [list of integers]
A list of 36 integers, with 4 integers being 1 and the rest being 0. Representing the distribution of the antipodal bearings of the straight line connecting the origin and destination across 36 bins. Also counting the antipodal bearings of an equally long straight perpendicular line intersecting the midpoint of the first.


#### 19. bearings_dist_od_directed_dist [list of integers]
A list of 36 integers, with one integer being 1 and the rest being 0. Representing the distribution of the bearing of the straight line connecting the origin and destination across 36 bins. Since it only concerns one bearing, the index with a value of one 1 represents the interval of bearings that the bearing from the origin to the destination is in.

#### 20. betweenness [float]
The average number of times that all shortest paths pass through an intersection in the street network.
Computed using networkx.betweenness_centrality: https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.betweenness_centrality.html 
With the weight parameter set to the length of the street.

#### 21. odpair_square_points [list of float tuples, [(x,y),(x,y),(x,y),(x,y)]]
A list of four coordinate points representing the square containing the OD-pair, used to select the part of the street network used to compute street orientations and street network properties.

A list of four points e.g. [(x,y),(x,y),(x,y),(x,y)] where x is the longitude and y is the latitude of a corner of this square. Using the WGS84 / EPSG:4326 coordinate reference system.

#### 22. fwd_angle [integer, compass bearing]
The compass bearing from the origin to the destination. Derived from column 19: bearings_dist_od_directed_dist where the bearings are grouped into 36 different bins, with the central bearing of the first bin being 0 degrees. 

For example, a fwd_angle of 90 means that direction from the origin to the destination points East.

#### 23. emd_36 [float]
The earth movers distance (EMD) that we evaluated as a metric of alignment between an OD-pair and street network. The EMD can be interpreted as the minimum effort required to transport earth from one pile to transform it into the shape of another pile of earth. In this dataset, it is the minimum effort required to rotate street orientations such that half of the streets are parallel with the OD-pair, and the other is orthogonal to the OD-pair.

emd_36 is computed between the circular distribution of orientations of the OD-pair (column 18: bearings_dist_od_undirected_dist_perp) and the circular distribution of surrounding street orientations (column bearings_dist_env_undirected_dist). Both distributions are normalized such that the sum of values in the distribution is equal to 1, then the EMD is computed following the equation for Circular Optimal Transport between two circular and discrete probability measures. This equation is described in section 2 in the paper below:
    
> Hundrieser, S., Klatt, M., & Munk, A. (2022). The Statistics of Circular Optimal Transport. In A. SenGupta & B. C. Arnold (Eds.), Directional Statistics for Innovative Applications: A Bicentennial Tribute to Florence Nightingale (pp. 57–82). Springer Nature. https://doi.org/10.1007/978-981-19-1044-9_4

#### 24. emd_1000 [float]

Same as emd_36, but when computing the EMD the distributions are first re-discretized across 1000 bins. Padding the distribution with zeroes before applying the same metric, to better approximate the empirical sample or continuous distribution.


#### 25. quantiles [string, factor]

The OD-pairs are split across 10 quantiles, Q1 to Q10, depending on how grid-like (column 10) the surrounding street network is.  Where OD-pairs in the least grid-like street network are in Quantile 1, and OD-pairs in the most grid-like street networks are in Quantile 10.



Reference information
---------------------
Abbreviations:
emd: Earth Mover's Distance
emd_36: Earth Mover's Distance calculated between discrete distributions with 36 bins.
emd_1000: Earth Mover's Distance calculated between discrete distributions rediscretized into 1000 bins.
betweenness: The average betweenness centrality of nodes in the surrounding street network
icd: InterConnection Density

Data sources:
OpenStreetMap

Source code information:
These libraries were used in python to create the dataset.
GitHub Page for the code used to create the dataset:
https://github.com/ArvHor/perceived-route-complexity

OSMNx v.2.0.1 https://osmnx.readthedocs.io/en/stable/
geopy https://geopy.readthedocs.io/en/stable/
overpy https://github.com/DinoTools/python-overpy
shapely https://shapely.readthedocs.io/en/stable/



