-
Notifications
You must be signed in to change notification settings - Fork 11
/
river_centerline_width_example_deprecation.py
127 lines (114 loc) · 6.17 KB
/
river_centerline_width_example_deprecation.py
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Find the center point and width between latitude/longitude points along right/left river bank
import centerline_width
if __name__ == "__main__":
centerline_width.extractPointsToTextFile(
left_kml="data/leftbank.kml",
right_kml="data/rightbank.kml",
text_output_name="data/river_coords.txt")
centerline_width.convertColumnsToCSV(text_file="data/river_coords.txt",
flip_direction=True)
#centerline_width.extractPointsToTextFile(left_kml="data/59deg48_18dot87_N_69deg46_59dot57_E_lb.kml",
# right_kml="data/59deg48_18dot87_N_69deg46_59dot57_E_rb.kml",
# text_output_name="data/N_output.txt")
#centerline_width.convertColumnsToCSV(text_file="data/river_coords.txt", flip_direction=True)
# Valid Examples
cutoff = None
#cutoff = 10
#cutoff = 15 # valid centerline, valid path, valid polygon, valid starting node, valid ending node
#cutoff = 30
#cutoff = 100 # valid centerline, valid path, valid polygon, valid starting node, valid ending node
cutoff = 550 # valid centerline, valid path, valid polygon, valid starting node, valid ending node
# Invalid Examples
#cutoff = 5 # invalid centerline, invalid path, valid polygon, invalid starting node, invalid ending nodes
#cutoff = 250 # valid centerline, valid path, invalid polygon, valid starting node, valid ending nodes
#cutoff = 40 # invalid centerline, valid path, valid polgyon, invalid starting node, valid ending node
#cutoff = 700 # invalid centerline, valid path, valid polgyon, invalid starting node, valid ending node
#cutoff = 1000 # invalid centerline, invalid path, invalid polgyon, invalid starting node, valid ending node
river = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=cutoff,
interpolate_data=False,
interpolate_n_centerpoints=None,
ellipsoid="WGS84")
#print(river)
#print(river.__dict__.keys())
print(f"centerlineVoronoi = {river.centerlineVoronoi}")
print(f"equalDistanceCenterline = {river.centerlineEqualDistance}")
print(f"centerlineEvenlySpaced = {river.centerlineEvenlySpaced}")
print(f"centerlineSmoothed = {river.centerlineSmoothed}")
print(f"\nCenterline Length = {river.centerlineLength} km")
print(f"Right Bank Length = {river.rightBankLength} km")
print(f"Left Bank Length = {river.leftBankLength} km")
print(f"centerlineVoronoiRelative = {river.centerlineVoronoiRelative}")
print(
f"equalDistanceCenterlineRelative = {river.centerlineEqualDistanceRelative}"
)
print(
f"centerlineEvenlySpacedRelative = {river.centerlineEvenlySpacedRelative}"
)
print(f"centerlineSmoothedRelative = {river.centerlineSmoothedRelative}")
print(f"Centerline Length = {river.centerlineLength * 1000} m")
print(f"ellipsoid = {river.ellipsoid}")
print(river.right_bank_relative_coordinates)
print(river.left_bank_relative_coordinates)
print(f"area = {river.area} m^2")
print(f"sinuosity = {river.sinuosity}")
incremental_sinuosity = river.incremental_sinuosity(incremental_points=215,
save_to_csv=None)
print(f"incremental sinuosity = {incremental_sinuosity}")
#exit()
#coord_type = "relative DIStance"
coord_type = "decimal degrees"
center_type = "VorOnoi"
#river.saveCenterlineCSV(save_to_csv="centerline_for_csv.csv",
# centerline_type=center_type,
# coordinate_unit=coord_type)
#river.saveCenterlineMAT(save_to_mat="centerline_for_matlab.mat", centerline_type=center_type, coordinate_unit=coord_type)
river.saveCenterlineCSV(save_to_csv="centerline_for_csv.csv",
latitude_header="lat",
longitude_header="long",
centerline_type="Equal Distance")
river.saveCenterlineMAT(save_to_mat="centerline_for_matlab.mat",
latitude_header="lat",
longitude_header="long",
centerline_type="Evenly Spaced")
river.plotCenterline(centerline_type="Evenly Spaced",
centerline_color="fuchsia",
marker_type="scatter",
dark_mode=True)
# Plot river bank centerline
river.plotCenterline(save_plot_name=None,
centerline_type=center_type,
marker_type="line",
centerline_color="black",
display_all_possible_paths=False,
display_voronoi=False,
plot_title=None,
dark_mode=True,
equal_axis=True,
show_plot=True,
coordinate_unit=coord_type)
transect = 5
slope_type = "average"
# Plot river bank width line
river.plotCenterlineWidth(save_plot_name=None,
plot_title=None,
display_true_centerline=False,
transect_span_distance=transect,
transect_slope=slope_type,
apply_smoothing=True,
flag_intersections=True,
remove_intersections=True,
dark_mode=True,
equal_axis=False,
show_plot=True,
coordinate_unit=coord_type)
# Return width line for each centerline coordinates
river_width_dict = river.riverWidthFromCenterline(
transect_span_distance=transect,
transect_slope=slope_type,
apply_smoothing=False,
remove_intersections=False,
save_to_csv=None,
coordinate_reference="banks",
coordinate_unit=coord_type)
print(f"\nriver width dict = {river_width_dict}\n")