Pedestrian Graph “Plan de la Limace”#
[1]:
import os
import sys
import matplotlib.pyplot as plt
# Ajout dans la variable PATH du système du chemin où est installée la librairie tracklib
module_path = os.path.abspath(os.path.join('../../../../tracklib'))
if module_path not in sys.path:
sys.path.append(module_path)
# Alias pour tracklib
import tracklib as tkl
# Ajout dans la variable PATH du système du chemin où est installée la librairie footprint2graph
module_path = os.path.abspath(os.path.join('../../..'))
if module_path not in sys.path:
sys.path.append(module_path)
[2]:
import matplotlib.pyplot as plt
import os
import time
from footprint2graph import run_iteration
from footprint2graph import read_config
from footprint2graph.util.Outdoorvision import load_raw_tracks_split
Chargement des paramètres#
[3]:
print ('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
print ('`````````````````````````````````````````````````````````````````````')
print (' Generate a footprint graph ')
print (' from hiking trajectories ')
print (' in the Bauges, summer 2024. ')
print ('’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’')
print ('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
print ('')
""" ======================================================================= """
""" Load parameters """
""" """
config_path = r'/home/md_vandamme/7_LIB/footprint2graph/data/config_bauges.yml'
config = read_config(config_path)
print('Paramètres relevés dans la configuration: ')
print ('Résultats enregistrés dans le répertoire: ', config['output']['RESULT_PATH'])
NBITER = int(config['graph_construction']['NUM_ITERATIONS'])
print ('Number of iterations: ', NBITER)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
`````````````````````````````````````````````````````````````````````
Generate a footprint graph
from hiking trajectories
in the Bauges, summer 2024.
’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Paramètres relevés dans la configuration:
Résultats enregistrés dans le répertoire: /home/md_vandamme/4_RESEAU/ZTEMPZ1/
Number of iterations: 2
Chargement des données#
Les données proviennent de la plateforme Outdoorvision. Après avoir été formatées au format CSV, elles sont chargées dans une collection qui servira d’entrée au pipeline.
[4]:
""" ======================================================================= """
""" Chargement de la collection de traces """
""" """
# chemin où sont stockés les traces Outdoorvision:
tracespathsource = r'/home/md_vandamme/5_GPS/OV/BAUGES/walk/'
# Paramètre : Coordonnées de la zone d'étude sur laquelle on construit le réseau
# Polygone sous la forme d'un tableau de X et de Y
# traces de la zone 1 (3km x 3km)
X = [950987, 951409, 950696, 949467, 947934, 948545, 950987]
Y = [6513197, 6512091, 6511113, 6510719, 6511949, 6512621, 6513197]
fmt = tkl.TrackFormat({'ext': 'CSV',
'srid': 'ENU',
'id_E': 1, 'id_N': 0, 'id_U': 3, 'id_T': 2,
'time_fmt': '2D/2M/4Y 2h:2m:2s',
'separator': ';',
'header': 0,
'cmt': '#',
'read_all': True})
collection = load_raw_tracks_split(config['output']['RESULT_PATH'],
tracespathsource, fmt, X, Y)
Loading and split outdoorvision track data...
Reading track data...
Number files to load: 4145
Starting split ...
500 / 4145
1000 / 4145
1500 / 4145
2000 / 4145
2500 / 4145
3000 / 4145
3500 / 4145
4000 / 4145
Number of tracks after split: 832
Lancement du pipeline#
[5]:
for idx in range(0, NBITER):
iteration_index = int(idx) + 1
# run pipeline for the ith iteration
run_iteration(iteration_index, config, collection)
print ('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
print ('`````````````````````````````````````````````````````````````````````')
print (' FIN ')
print ('’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’')
print ('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
-----------------------------------------------------------------
-----------------------------------------------------------------
ITERATION 1
-----------------------------------------------------------------
-----------------------------------------------------------------
Starting segmentation and resampling...
Starting segmentation ...
500 / 832
Number of tracks after segmentation: 1171
Finished saving segmented tracks.
Starting resampling ...
Number of tracks to resample: 1171
Number of tracks after resampling: 1171
Number of tracks after resampling: 1171
Finished saving resampled tracks.
Stage 1 finished: segmentation and resampling.
Starting rasterization and vectorization (iteration 1)
Loading tracks from : resample_grid
Number of tracks to load: 1171
Building high-resolution geometry density grid G1 : 2 m ...
Building low-resolution contextual density grid G2 : 30 m ...
Assigning track points to the G1 and G2 grids
500 / 1171
1000 / 1171
Computing G1 ...
Computing G2 ...
Number of neighboring cells to consider: 7
Building contrast grid : 2 m
Execution time (seconds): 144.73467755317688
Finished heatmap computation.
Starting morphological closing image ...
Execution time (seconds): 32.976491928100586
Finished morphological opening.
Vectorizing cleaned image ...
Extracting road surface vector features ...
Number of polygonize features: 51
Number of polygonize features copied: 8
Execution time (seconds): 0.1599118709564209
Vectorization completed.
Smoothing polygon to remove stair-step artifacts ...
100% (279 of 279) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (279 of 279) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (406 of 406) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (358 of 358) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (211 of 211) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (1204 of 1204) |####################| Elapsed Time: 0:00:00 Time: 0:00:00
0% (0 of 3195) | | Elapsed Time: 0:00:00 ETA: --:--:--
Execution time (seconds): 1.43650484085083
Road surface smoothing completed.
Starting centerline computation ...
100% (3195 of 3195) |####################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (3191 of 3191) |####################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (21702 of 21702) |##################| Elapsed Time: 0:00:00 Time: 0:00:000000
Execution time (seconds): 3.4315288066864014
Centerline computed.
Stage 2 completed: rasterization and vectorization.
Starting topology creation for the network
Number of edges in the skeleton: 5058
Finished loaded skeleton.
/home/md_vandamme/4_RESEAU/ZTEMPZ1/network/tmp_in.csv not exists
/home/md_vandamme/4_RESEAU/ZTEMPZ1/network/tmp_out.csv not exists
32% (33 of 102) |####### | Elapsed Time: 0:00:00 ETA: 0:00:00
Finished removing hooked parts of the skeleton.
100% (102 of 102) |######################| Elapsed Time: 0:00:01 Time: 0:00:010000
100% (102 of 102) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
Finished simplification of the skeleton.
Building [100 x 75] spatial index...
on coupe la trace 2
on coupe la trace 1
on coupe la trace 1
Number of edges in the skeleton (after snapping): 105
Edge count difference after snapping : 3
Number of edges in the simplified skeleton: 66
Number of nodes: 72
Shortest edges limit : 50
Number of edges in the skeleton (after removing the shortest edges): 0
Conflation cannot be performed for node 59 ; the three incident edges are too long: 211 368 210
Conflation cannot be performed for node 60 ; the three incident edges are too long: 211 210 1188
Conflation cannot be performed for node 76 ; the three incident edges are too long: 9 207 448
Conflation cannot be performed for node 77 ; the three incident edges are too long: 9 109 1188
Conflation cannot be performed for node 93 ; the three incident edges are too long: 48 341 511
Conflation cannot be performed for node 98 ; the three incident edges are too long: 759 341 511
Conflation cannot be performed for node 107 ; the three incident edges are too long: 48 3928 1490
Conflation cannot be performed for node 103 ; the three incident edges are too long: 448 153 617
Conflation cannot be performed for node 50 ; the three incident edges are too long: 759 418 368
Conflation cannot be performed for node 82 ; the three incident edges are too long: 153 217 3928
Edge count after conflation: 26
Stage 3 completed: adding topology to the skeleton.
Starting map-matching, aggregation, and conflation of GNSS trajectories.
Loading network (1) ...
Number of edges = 26
Number of nodes = 32
Total segment length of the network = 13265.887004361779
Loading collection of tracks ...
100% (32 of 32) |########################| Elapsed Time: 0:00:00 Time: 0:00:00
Number of tracks: 1171
Execution time (seconds): 7.991522789001465
Starting map-matching ...
Index spatial : [100 x 75] spatial index centered on [949571.1447794335; 6511919.456318483]
Map-matching preparation...
Parameter search_radius: 25
Map-matching ended.
Execution time (seconds): 1687.354591369629
Prepare map-matching results for candidate segment generation
Number of map-matched points = 812751 (96.5 %)
Map-matching results restructuring completed.
Map-matching results exported.
Starting construction of candidate trajectory segments for each topology edge ...
221 candidates for edge 119
84 candidates for edge 35
111 candidates for edge 148
78 candidates for edge 156
218 candidates for edge 47
54 candidates for edge 67
7 candidates for edge 54
65 candidates for edge 75
276 candidates for edge 130
119 candidates for edge 140
102 candidates for edge 154
205 candidates for edge 161
213 candidates for edge 98
459 candidates for edge 141
32 candidates for edge 146
257 candidates for edge 163
825 candidates for edge 90
14 candidates for edge 118
40 candidates for edge 144
40 candidates for edge 16
81 candidates for edge 116
14 candidates for edge 9
73 candidates for edge 147
32 candidates for edge 77
36 candidates for edge 13
9 candidates for edge 112
Number of processed edges: 26
Minimum number of candidate tracks per edge: 7
Maximum number of candidate traces per edge: 825
Average number of candidate tracks per edge: 141
Segment construction completed.
Execution time (seconds): 41.64723253250122
Starting track segment aggregation for all network edges ...
Number of candidate tracks / number of sampled tracks 221 / 30
Number of candidate tracks / number of sampled tracks 84 / 30
Number of candidate tracks / number of sampled tracks 111 / 30
Number of candidate tracks / number of sampled tracks 78 / 30
Number of candidate tracks / number of sampled tracks 54 / 30
Number of candidate tracks / number of sampled tracks 7 / 7
Number of candidate tracks / number of sampled tracks 65 / 30
Number of candidate tracks / number of sampled tracks 276 / 30
Number of candidate tracks / number of sampled tracks 119 / 30
Number of candidate tracks / number of sampled tracks 102 / 30
Number of candidate tracks / number of sampled tracks 205 / 30
WARNING: TRAJECTORY FUSION HAS NOT CONVERGED (#ITER = 25 - CV = 0.0068389902972801455)
Number of candidate tracks / number of sampled tracks 213 / 30
Number of candidate tracks / number of sampled tracks 459 / 30
Number of candidate tracks / number of sampled tracks 32 / 30
Number of candidate tracks / number of sampled tracks 257 / 30
Number of candidate tracks / number of sampled tracks 825 / 30
Number of candidate tracks / number of sampled tracks 14 / 14
Number of candidate tracks / number of sampled tracks 40 / 30
Number of candidate tracks / number of sampled tracks 40 / 30
Number of candidate tracks / number of sampled tracks 81 / 30
Number of candidate tracks / number of sampled tracks 14 / 14
Number of candidate tracks / number of sampled tracks 73 / 30
Number of candidate tracks / number of sampled tracks 32 / 30
Number of candidate tracks / number of sampled tracks 36 / 30
Number of candidate tracks / number of sampled tracks 9 / 9
Number of aggregations: 26
Number of aggregations with 30 traces: 21
Number of aggregations with fewer than 30 traces: 4
Minimum number of traces in aggregation: 7
Average number of traces in aggregation: 133
Aggregation process finished.
Execution time (seconds): 44.12959551811218
Starting conflation ...
Conflation process finished.
Execution time (seconds): 0.05499768257141113
Stage 4 completed: map-matching, aggregation, and conflation.
-----------------------------------------------------------------
-----------------------------------------------------------------
ITERATION 2
-----------------------------------------------------------------
-----------------------------------------------------------------
Number of tracks map matched : 1171
1605
Starting rasterization and vectorization (iteration 2)
Loading tracks from : points_not_mm_2
Number of tracks to load: 1605
Building high-resolution geometry density grid G1 : 2 m ...
Building low-resolution contextual density grid G2 : 30 m ...
Assigning track points to the G1 and G2 grids
500 / 1605
1000 / 1605
1500 / 1605
Computing G1 ...
Computing G2 ...
Number of neighboring cells to consider: 7
Building contrast grid : 2 m
Execution time (seconds): 54.55560350418091
Finished heatmap computation.
Starting morphological closing image ...
Execution time (seconds): 33.21741557121277
Finished morphological opening.
Vectorizing cleaned image ...
Extracting road surface vector features ...
Number of polygonize features: 60
Number of polygonize features copied: 25
Execution time (seconds): 0.12494230270385742
Vectorization completed.
Smoothing polygon to remove stair-step artifacts ...
100% (297 of 297) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (447 of 447) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (253 of 253) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (130 of 130) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (486 of 486) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (162 of 162) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (321 of 321) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (152 of 152) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (198 of 198) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
0% (0 of 215) | | Elapsed Time: 0:00:00 ETA: --:--:--
Execution time (seconds): 0.36910533905029297
Road surface smoothing completed.
Starting centerline computation ...
100% (215 of 215) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (161 of 161) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (137 of 137) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (220 of 220) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (193 of 193) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (234 of 234) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (153 of 153) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (148 of 148) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (202 of 202) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (175 of 175) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (121 of 121) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (141 of 141) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (188 of 188) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (145 of 145) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (238 of 238) |######################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (3193 of 3193) |####################| Elapsed Time: 0:00:00 Time: 0:00:00
100% (3189 of 3189) |####################| Elapsed Time: 0:00:00 Time: 0:00:00
Execution time (seconds): 0.8457791805267334
Centerline computed.
Stage 2 completed: rasterization and vectorization.
Starting topology creation for the network
Number of edges in the skeleton: 921
Finished loaded skeleton.
68% (41 of 60) |################ | Elapsed Time: 0:00:00 ETA: 0:00:00
Finished removing hooked parts of the skeleton.
100% (60 of 60) |########################| Elapsed Time: 0:00:00 Time: 0:00:000:00
100% (60 of 60) |########################| Elapsed Time: 0:00:00 Time: 0:00:00
Finished simplification of the skeleton.
Building [100 x 82] spatial index...
Number of edges in the skeleton (after snapping): 60
Edge count difference after snapping : 0
Number of edges in the simplified skeleton: 55
Number of nodes: 79
Shortest edges limit : 50
Number of edges in the skeleton (after removing the shortest edges): 1
Conflation cannot be performed for node 19 ; the three incident edges are too long: 19 52 31
Edge count after conflation: 28
Stage 3 completed: adding topology to the skeleton.
Starting map-matching, aggregation, and conflation of GNSS trajectories.
Loading network (2) ...
Number of edges = 28
Number of nodes = 51
Total segment length of the network = 2359.038212864578
Loading collection of tracks ...
100% (51 of 51) |########################| Elapsed Time: 0:00:00 Time: 0:00:00
Number of tracks: 1605
Execution time (seconds): 3.1663522720336914
Starting map-matching ...
Index spatial : [100 x 82] spatial index centered on [950195.6342437908; 6511752.969261601]
Map-matching preparation...
Parameter search_radius: 25
Map-matching ended.
Execution time (seconds): 23.73816752433777
Prepare map-matching results for candidate segment generation
Number of map-matched points = 103337 (46.87 %)
Map-matching results restructuring completed.
Map-matching results exported.
Starting construction of candidate trajectory segments for each topology edge ...
6 candidates for edge 70
15 candidates for edge 63
3 candidates for edge 68
9 candidates for edge 62
46 candidates for edge 60
6 candidates for edge 35
6 candidates for edge 71
10 candidates for edge 66
11 candidates for edge 74
6 candidates for edge 64
19 candidates for edge 44
15 candidates for edge 27
2 candidates for edge 73
3 candidates for edge 30
5 candidates for edge 76
7 candidates for edge 75
6 candidates for edge 45
4 candidates for edge 69
24 candidates for edge 0
27 candidates for edge 1
11 candidates for edge 15
3 candidates for edge 77
0 candidates for edge 72
7 candidates for edge 67
9 candidates for edge 59
3 candidates for edge 55
9 candidates for edge 46
4 candidates for edge 8
Number of processed edges: 28
Minimum number of candidate tracks per edge: 0
Maximum number of candidate traces per edge: 46
Average number of candidate tracks per edge: 10
Segment construction completed.
Execution time (seconds): 7.026676893234253
Starting track segment aggregation for all network edges ...
Number of candidate tracks / number of sampled tracks 6 / 6
Number of candidate tracks / number of sampled tracks 15 / 15
Number of candidate tracks / number of sampled tracks 3 / 3
Number of candidate tracks / number of sampled tracks 9 / 9
Number of candidate tracks / number of sampled tracks 46 / 30
Number of candidate tracks / number of sampled tracks 6 / 6
Number of candidate tracks / number of sampled tracks 6 / 6
Number of candidate tracks / number of sampled tracks 10 / 10
Number of candidate tracks / number of sampled tracks 11 / 11
Number of candidate tracks / number of sampled tracks 6 / 6
Number of candidate tracks / number of sampled tracks 19 / 19
Number of candidate tracks / number of sampled tracks 15 / 15
Number of candidate tracks / number of sampled tracks 2 / 2
Number of candidate tracks / number of sampled tracks 3 / 3
Number of candidate tracks / number of sampled tracks 5 / 5
Number of candidate tracks / number of sampled tracks 7 / 7
Number of candidate tracks / number of sampled tracks 6 / 6
Number of candidate tracks / number of sampled tracks 4 / 4
Number of candidate tracks / number of sampled tracks 11 / 11
Number of candidate tracks / number of sampled tracks 3 / 3
Number of candidate tracks / number of sampled tracks 7 / 7
Number of candidate tracks / number of sampled tracks 9 / 9
Number of candidate tracks / number of sampled tracks 3 / 3
Number of candidate tracks / number of sampled tracks 9 / 9
Number of candidate tracks / number of sampled tracks 4 / 4
Number of aggregations: 27
Number of aggregations with 30 traces: 1
Number of aggregations with fewer than 30 traces: 24
Minimum number of traces in aggregation: 2
Average number of traces in aggregation: 8
Aggregation process finished.
Execution time (seconds): 1.2899436950683594
Starting conflation ...
Conflation process finished.
Execution time (seconds): 0.017225027084350586
Stage 4 completed: map-matching, aggregation, and conflation.
1315.3142746399594
100% (53 of 53) |########################| Elapsed Time: 0:00:00 Time: 0:00:00
Size of collection In : 26
Size of collection In+1: 27
Size of collection In+In+1: 53
Building [100 x 74] spatial index...
Size of collection In+In+1 avec intersection: 55
Size of collection In+In+1 avec intersection et raccordement: 82
Size of reseau de mobilité: 82
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
`````````````````````````````````````````````````````````````````````
FIN
’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
On affiche le résultat#
[6]:
from footprint2graph.util.PlotRes import plotResultatFinal
plotResultatFinal(config['output']['RESULT_PATH'])