-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencodePath.py
More file actions
61 lines (56 loc) · 1.61 KB
/
encodePath.py
File metadata and controls
61 lines (56 loc) · 1.61 KB
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
from shapely.geometry import LineString
from shapely import to_wkb
# your waypoints (lat, lon) pairs
coords_latlon = [
(45.42213, -75.68145),
(45.42227, -75.68156),
(45.4225 , -75.68176),
(45.42262, -75.68187),
(45.42267, -75.68192),
(45.42275, -75.68198),
(45.423 , -75.68219),
(45.42325, -75.68239),
(45.42328, -75.68242),
(45.42331, -75.68245),
(45.42331, -75.68245),
(45.42334, -75.68237),
(45.42352, -75.68193),
(45.42354, -75.68189),
(45.42365, -75.68162),
(45.42369, -75.68152),
(45.42369, -75.68152),
(45.42363, -75.68147),
(45.4236 , -75.68145),
(45.42316, -75.68108),
(45.42314, -75.68106),
(45.42289, -75.68086),
(45.42264, -75.68065),
(45.42247, -75.68051),
(45.4224 , -75.68045),
(45.42212, -75.68022),
(45.42207, -75.68018),
(45.42201, -75.68012),
(45.42166, -75.67983),
(45.42144, -75.67964),
(45.42091, -75.67919),
(45.42066, -75.67898),
(45.42059, -75.67892),
(45.42053, -75.67887),
(45.42051, -75.67885),
(45.42047, -75.67882),
(45.41992, -75.67837),
(45.41992, -75.67837),
(45.41988, -75.67844),
(45.41979, -75.67855),
(45.41973, -75.67863),
(45.41967, -75.67869),
(45.41967, -75.67869),
]
# Note: WKT/WKB typically expects (lon, lat) i.e. (x, y) order for geographic coords.
coords_lonlat = [(lng, lat) for lat, lng in coords_latlon]
# create LineString geometry
line = LineString(coords_lonlat)
# export to WKB hex, include SRID (4326) if needed
wkb_hex = to_wkb(line, hex=True, include_srid=True)
print("WKB (hex) with SRID=4326:")
print(wkb_hex)