Skip to content

Commit

Permalink
v0.2.5 release with width centerline bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cyschneck committed Jun 3, 2023
1 parent c129543 commit 9d8ced1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
3 changes: 2 additions & 1 deletion centerline_width/centerline.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ def riverWidthFromCenterline(river_object=None,
defined_centerline_coordinates = centerline_width.evenlySpacedCenterline(centerline_coordinates=river_object.centerlineVoronoi,
number_of_fixed_points=river_object.interpolate_n_centerpoints)
if apply_smoothing:
defined_centerline_coordinates = centerline_width.smoothedCoordinates(centerline_coordinates=river_object.centerlineVoronoi,
defined_centerline_coordinates = centerline_width.smoothedCoordinates(river_object=river_object,
centerline_coordinates=river_object.centerlineVoronoi,
interprolate_num=river_object.interpolate_n_centerpoints)
# if using smoothing, replace left/right coordinates with the smoothed variation
right_width_coord, left_width_coord, _ = centerline_width.riverWidthFromCenterlineCoordinates(river_object=river_object,
Expand Down
27 changes: 14 additions & 13 deletions river_centerline_width_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,32 @@
# right_kml="data/rightbank.kml",
# text_output_name="data/river_coords.txt")
#print("new data with gap: N8_R1/N8_R2.kml")
centerline_width.extractPointsToTextFile(left_kml="data/N8_R1.kml",
right_kml="data/N8_R2.kml",
centerline_width.extractPointsToTextFile(left_kml="data/left.kml",
right_kml="data/right.kml",
text_output_name="data/N_output.txt")
centerline_width.convertColumnsToCSV(text_file="data/N_output.txt", flipBankDirection=True)
centerline_width.convertColumnsToCSV(text_file="data/N_output.txt", flipBankDirection=False)

# 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
#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",
river = centerline_width.riverCenterline(csv_data="data/N_output.csv",
optional_cutoff=cutoff,
interpolate_data=False,
interpolate_n_centerpoints=200)
interpolate_data=True,
interpolate_n=10,
interpolate_n_centerpoints=62)
#print(river)
print(river.__dict__.keys())
#print(river.__dict__.keys())
print("Centerline Length = {0} km".format(river.centerlineLength))
print("Right Bank Length = {0} km".format(river.rightBankLength))
print("Left Bank Length = {0} km".format(river.leftBankLength))
Expand All @@ -41,16 +42,16 @@


# Plot river bank centerline
river.plotCenterline(save_plot_name=None,
display_all_possible_paths=False,
display_voronoi=False)
#river.plotCenterline(save_plot_name=None,
# display_all_possible_paths=False,
# display_voronoi=False)

transect = 3

# Plot river bank width line
river.plotCenterlineWidth(save_plot_name=None,
plot_title=None,
display_true_centerline=False,
display_true_centerline=True,
transect_span_distance=transect,
apply_smoothing=True,
flag_intersections=False,
Expand All @@ -63,4 +64,4 @@
units="m",
save_to_csv=None)

#print("\nriver width dict = {0}\n".format(river_width_dict))
print("\nriver width dict = {0}\n".format(river_width_dict))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Python Package Setup
from setuptools import setup, find_namespace_packages

VERSION="0.2.4"
VERSION="0.2.5"
DESCRIPTION="A Python package to find the centerline and width of rivers based on the latitude and longitude of the right and left bank"

with open("README.md", "r") as f:
Expand Down

0 comments on commit 9d8ced1

Please sign in to comment.