cartagen.rural_traffic#
- rural_traffic(roads, min_traffic=1, attraction_points=None, max_distance=None, sample_size=80, export_samples=False, cost=None)#
Detect central roads inside a network using traffic simulation.
This algorithm proposed by Touya [1] detects the most used road inside a network by simulating traffic between attraction points. Thos points can be provided or they can randomly be extracted from the network.
- Parameters:
roads (
GeoDataFrameofLineString) – The road network to analyze.min_traffic (
int, optional) – The minimum number of time a road must be used to be kept.attraction_points (
GeoDataFrameofPoint, optional) – The attraction points between which traffic will be calculated. If provided, the points doesn’t need to be on the network, they will be snapped to the closest node (i.e. intersection) on the network. Default to None, meaning a random set a nodes will be taken.max_distance (
int, optional) – If attraction points are provided, it is the maximum distance from which the provided attraction points are snapped to the road network nodes. If further from this distance, the point will not be used. Default to None, meaning the point is snapped no matter its distance from the network.sample_size (
int, optional) – If no attraction points are provided, it is the number of nodes to take into account when calculating traffic. This means the calculation between all pairs of nodes, this can be really resource-intensive.export_samples (
bool, optional) – If set to True, returns a tuple of two GeoDataFrame instead of a single GeoDataFrame. The second is a point GeoDataFrame of the samples used for the traffic calculation. If attraction points were provided, returns the snapped points on the nodes, else returns the random node sample.cost (
str, optional) – The name of the attribute giving the cost of the road section. Make sure the attribute is a number. Default to None, which means the length of the road is used as the cost.
- Returns:
roads (
GeoDataFrameofLineString) – The network with simulated traffic information : - ‘rural’: boolean indicating whether the route has a traffic value greater than the min_traffic threshold. - ‘traffic’: number of times the road section is part of the shortest route between two points of attraction.samples (
GeoDataFrameofPoint, optional) – The random sample if wanted, and if no attraction points were provided.
Warning
This algorithm can quickly become very intensive, especially when using a large dataset and a high
sample_sizeparameter, but it preserves the connectivity of the network.See also
rural_betweenessDetect central roads inside a network using traffic simulation.
References