1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| import matplotlib.pyplot as plt
from shapely.geometry import LineString
# Coordonnées des points GPS
coords = [
(43.86813557333333, 5.084475755),
(43.86812814333334, 5.084537345),
(43.86812745, 5.084551955),
(43.86810116, 5.084578025),
(43.868104536666664, 5.084578775),
(43.868104865, 5.08457851),
(43.868104865, 5.08457851),
(43.868094666666664, 5.0846223083333335),
(43.86808087, 5.084651008333333),
(43.868069425, 5.084677441666667),
(43.868060281666665, 5.084690403333333),
#(43.86802160166667, 5.084784855),
#(43.86796747333333, 5.084810366666667),
#(43.86797120666667, 5.084804748333333),
(43.867972695, 5.084802591666667),
(43.86797477333333, 5.084801596666667),
(43.86794952166667, 5.084933823333333),
(43.86792595833333, 5.084927461666667),
(43.867920745, 5.084927331666667),
(43.86791683333333, 5.084934075),
(43.86791683333333, 5.084934075),
(43.867914436666666, 5.0849431916666665),
(43.867914436666666, 5.0849431916666665),
(43.867905035, 5.08500559),
(43.86790705333333, 5.08501316),
(43.86790564333333, 5.085010901666666),
(43.867900608333336, 5.085009266666667),
(43.86787631833333, 5.084999491666666),
(43.86787631833333, 5.084999491666666),
(43.867867716666666, 5.08499414),
(43.867859626666664, 5.0849913),
(43.867852035, 5.0849899616666665),
(43.86782328, 5.084977881666667),
(43.86785492833334, 5.084700065),
(43.86783610333333, 5.084675985),
(43.86785712166667, 5.084523676666667),
(43.867870315, 5.084365421666667),
(43.867926875, 5.084017386666667),
(43.86808408666667, 5.0840620733333335),
(43.868076306666666, 5.084092915),
(43.86802215666667, 5.084078638333334),
(43.868009771666664, 5.084080471666667),
(43.86800565833333, 5.084114193333333),
(43.86799056833333, 5.084237133333334),
(43.868090308333336, 5.0842674783333335),
(43.86809951666667, 5.084289266666667),
(43.868105871666664, 5.084294903333333),
(43.868121466666665, 5.084319156666667),
(43.86813372, 5.084342313333333),
(43.86814266333333, 5.084392235),
(43.86813333166667, 5.0844649466666665)
]
# Création de la ligne à partir des coordonnées
line = LineString(coords)
# Décalage parallèle de la ligne (vers la gauche)
offset = line.parallel_offset(0.000008, 'left', join_style=3, mitre_limit=5)
# Inversion des coordonnées x et y pour l'affichage
coords_x_inverted = [(coord[1], coord[0]) for coord in coords]
offset_x_inverted = [(coord[1], coord[0]) for coord in offset.coords]
# Affichage des lignes
fig, ax = plt.subplots()
ax.plot(*zip(*coords_x_inverted), color='blue') # Ligne originale
# Tracer chaque point de la géométrie décalée
for point in offset_x_inverted:
ax.plot(point[0], point[1], 'ro') # 'ro' pour indiquer des points rouges
# Tracer des lignes entre les points rouges
for i in range(len(offset_x_inverted) - 1):
ax.plot([offset_x_inverted[i][0], offset_x_inverted[i+1][0]],
[offset_x_inverted[i][1], offset_x_inverted[i+1][1]], color='red')
plt.show() |
Partager