Skip to content

Commit

Permalink
plotCenterline() README images
Browse files Browse the repository at this point in the history
  • Loading branch information
cyschneck committed Apr 15, 2024
1 parent 03155bc commit 31ecf61
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 27 deletions.
75 changes: 70 additions & 5 deletions README.md
Expand Up @@ -383,7 +383,7 @@ Return the area contained within the polygon generated the left and right bank l
```
river_object.riverArea
```
Length returned in kilometers^2
Area returned in kilometers^2
```python
import centerline_width
river_object = centerline_width.riverCenterline(csv_data="data/river_coords.csv")
Expand Down Expand Up @@ -413,7 +413,7 @@ plotCenterline(centerline_type="Voronoi",
* [OPTIONAL] dark_mode (bool): Change plot to a black ground (and override if `centerline_color="black"` to `centerline_color="white"`), defaults to False
* [OPTIONAL] equal_axis (bool): Set x/y axes in plot to be equal, defaults to False
* [OPTIONAL] display_all_possible_paths (boolean): Display all possible paths, not just the centerline (useful for debugging), defaults to False
* [OPTIONAL] plot_title (string): Change plot title, defaults to "River Coordinates: Valid Centerline = True/False, Valid Polygon = True/False"
* [OPTIONAL] plot_title (string): Change plot title, defaults to "River Coordinates: Valid Centerline = True/False, Valid Polygon = True/False, Interpolated = True/False"
* [OPTIONAL] save_plot_name (string): Save the plot with a given name and location
* [OPTIONAL] display_voronoi (boolean): Overlay Voronoi diagram used to generate centerline, defaults to False
* [OPTIONAL] show_plot (boolean): display and open plots (plt.show() in Matplotlib), defaults to True
Expand All @@ -424,9 +424,74 @@ import centerline_width
river_object = centerline_width.riverCenterline(csv_data="data/river_coords.csv")
river_object.plotCenterline()
```
Output:
![river_coords_centerline+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_centerline.png)

**centerline_type**

Display different centerline types in plot ("Voronoi", "Evenly Spaced", "Smoothed", "Equal Distance"), but defaults to "Voronoi"

| centerline_type="Voronoi" | centerline_type="Smoothed" |
| ------------- | ------------- |
| ![centerline_type_voronoi+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_centerline.png) | ![centerline_type_equal_distance+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_centerline_type_smoothed.png) |

**marker_type**

Display centerline plot as either line or scatter

| marker_type="Line" | marker_type="Scatter" |
| ------------- | ------------- |
| ![marker_type_line+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_centerline.png) | ![marker_type_scatter+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_marker_type_scatter.png) |

**centerline_color**

Change the color of the centerline, defaults to black

| centerline_color="black" | centerline_color="purple" |
| ------------- | ------------- |
| ![centerline_color_black+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_centerline.png) | ![centerline_color_purple+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_centerline_color.png) |

**dark_mode**

dark_mode will change the default Matplotlib background black and swap `centerline_color` from default black to white

| dark_mode=False | dark_mode=True |
| ------------- | ------------- |
| ![dark_mode_false+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_centerline.png) | ![dark_mode_true+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_dark_mode.png) |

**equal_axis**

equal_axis will set the x and y axis of the plot to be equal

| equal_axis=False | equal_axis=True |
| ------------- | ------------- |
| ![river_not_equal+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_equal_axis_false.png) | ![river_equal+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_equal_axis_true.png)|

**display_all_possible_paths**

Display all possible paths generated by Voronoi edge ridges, defaults to False

| display_all_possible_paths=False | display_all_possible_paths=True |
| ------------- | ------------- |
| ![display_all_possible_paths_false+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_centerline.png) | ![display_all_possible_paths_true+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_display_all_possible_paths_true.png) |

**display_voronoi**

Overlay Voronoi diagram used to generate centerline, defaults to False

| display_voronoi=False | display_voronoi=True |
| ------------- | ------------- |
| ![display_voronoi_default+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_centerline.png) | ![display_voronoi_true+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_display_voronoi_true.png) |


**coordinate_unit**

Plot as either "Decimal Degrees" and "Relative Distance". defaults to "Decimal Degrees"

| coordinate_unit="Decimal Degrees" | coordinate_unit="Relative Distance" |
| ------------- | ------------- |
| ![coordinate_unit_dd+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_centerline.png) | ![coordinate_unit_rd+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coordinate_unit_rd.png) |


## Plot Centerline Width Lines in Matplotlib
### Plot the Centerline Width Lines
Plot the width of the river based on the centerline
Expand All @@ -445,7 +510,7 @@ plotCenterlineWidth(plot_title=None,
show_plot=True,
coordinate_unit="Decimal Degrees")
```
* [OPTIONAL] plot_title (string): Change plot title, defaults to "River Coordinates: Valid Centerline = True/False, Valid Polygon = True/False"
* [OPTIONAL] plot_title (string): Change plot title, defaults to "River Width Coordinates: Valid Centerline = True/False, Valid Polygon = True/False, Centerline made of <interpolate_n_centerpoints> Fixed Points, width lines generated every <transect_span_distance> points, Interpolated = True/False"
* [OPTIONAL] save_plot_name (string): Save the plot with a given name and location
* [OPTIONAL] display_true_centerline (boolean): Display generated true centerline based on Voronoi diagrams, defaults to True
* [OPTIONAL] transect_span_distance (int): Number n points around a center point to determine the slope (increase to decrease the impact of sudden changes), defaults to 3, must be greater than 1 (since the slope is found from the difference in position between two points)
Expand Down Expand Up @@ -519,7 +584,7 @@ Intersecting lines are flagged in red by default (flag_intersections=True)

**dark_mode**

dark_mode will change the default Matplotlib background black and swap `centerline_color` from black to white
dark_mode will change the default Matplotlib background black and swap `centerline_color` from default black to white

| dark_mode=False | dark_mode=True |
| ------------- | ------------- |
Expand Down
Binary file modified data/doc_examples/algorithm_step8.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/doc_examples/river_centerline_color.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/doc_examples/river_coordinate_unit_rd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/doc_examples/river_dark_mode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/doc_examples/river_display_voronoi_true.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/doc_examples/river_equal_axis_false.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/doc_examples/river_equal_axis_true.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/doc_examples/river_marker_type_scatter.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 56 additions & 22 deletions generate_readme_diagrams.py
Expand Up @@ -11,7 +11,18 @@
text_output_name="data/river_coords.txt")
centerline_width.convertColumnsToCSV(text_file="data/river_coords.txt",
flip_direction=True)

ro_5 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=5)
ro_10 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=10)
ro_15 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=15)
ro_250 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=250)
ro_550 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=550)
ro_725 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=725)
is_debug = False # set to False when generating, True when debugging to view all plots

################### Introduction and Quickstart ##########################################
Expand All @@ -22,9 +33,6 @@
plot_title="Centerline with Riverbanks",
save_plot_name="data/doc_examples/river_example.png",
show_plot=is_debug)

ro_550 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=550)
ro_550.plotCenterline(
save_plot_name="data/doc_examples/river_coords_centerline.png",
show_plot=is_debug)
Expand Down Expand Up @@ -80,7 +88,6 @@
plot_title=
"Centerline Formed by Voronoi Diagram with Relative Distance",
show_plot=is_debug)

ro_550.plotCenterline(
save_plot_name="data/doc_examples/equal_distance_centerline.png",
centerline_type="Equal Distance",
Expand All @@ -99,7 +106,6 @@
plot_title=
f"Centerline Formed by Points Equally Distanced Apart Every {ro_550.equal_distance} Meters with Relative Distance",
show_plot=is_debug)

ro_550_interpolate_centerline_200.plotCenterline(
save_plot_name="data/doc_examples/evenly_spaced_centerline.png",
centerline_type="Evenly Spaced",
Expand All @@ -118,7 +124,6 @@
plot_title=
f"Centerline Formed by {ro_550_interpolate_centerline_200.interpolate_n_centerpoints} Evenly Spaced Centerline Points with Relative Distance",
show_plot=is_debug)

ro_550_interpolate_centerline_200.plotCenterline(
save_plot_name="data/doc_examples/smoothed_centerline.png",
centerline_type="Smoothed",
Expand All @@ -137,7 +142,48 @@
f"Centerline Formed by {ro_550_interpolate_centerline_200.interpolate_n_centerpoints} Smoothed Centerline Coordinates with Relative Distance",
show_plot=is_debug)

################### Plot Centerline Width Lines in Matplotlib ###############################
################### Plot plotCenterline() #############################################

ro_550.plotCenterline(
centerline_type="Smoothed",
save_plot_name="data/doc_examples/river_centerline_type_smoothed.png",
show_plot=is_debug)
ro_550.plotCenterline(
marker_type="Scatter",
save_plot_name="data/doc_examples/river_marker_type_scatter.png",
show_plot=is_debug)
ro_550.plotCenterline(
centerline_color="purple",
save_plot_name="data/doc_examples/river_centerline_color.png",
show_plot=is_debug)
ro_550.plotCenterline(
dark_mode=True,
save_plot_name="data/doc_examples/river_dark_mode.png",
show_plot=is_debug)
ro_15.plotCenterline(
equal_axis=False,
save_plot_name="data/doc_examples/river_equal_axis_false.png",
show_plot=is_debug)
ro_15.plotCenterline(
equal_axis=True,
save_plot_name="data/doc_examples/river_equal_axis_true.png",
show_plot=is_debug)
ro_550.plotCenterline(
display_all_possible_paths=True,
save_plot_name=
"data/doc_examples/river_display_all_possible_paths_true.png",
show_plot=is_debug)
ro_550.plotCenterline(
display_voronoi=True,
save_plot_name="data/doc_examples/river_display_voronoi_true.png",
show_plot=is_debug)
ro_550.plotCenterline(
coordinate_unit="Relative Distance",
save_plot_name="data/doc_examples/river_coordinate_unit_rd.png",
show_plot=is_debug)

################### Plot plotCenterlineWidth() ########################################

ro_550.plotCenterlineWidth(
save_plot_name="data/doc_examples/river_coords_with_centerline.png",
display_true_centerline=True,
Expand Down Expand Up @@ -220,8 +266,6 @@
remove_intersections=False,
dark_mode=True,
show_plot=is_debug)
ro_10 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=10)
ro_10.plotCenterlineWidth(
save_plot_name=
"data/doc_examples/river_coords_not_equal_default_ax.png",
Expand Down Expand Up @@ -253,8 +297,7 @@
show_plot=is_debug)

################### Algorithm to Determine Centerline ###############################
ro_15 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=15)


def plotAlgorithm(fig_save_name=None,
plot_polygon=False,
Expand Down Expand Up @@ -406,30 +449,21 @@ def plotNetworkXGraph(fig_save_name=None):

################### Debugging, Error Handling, and Edge Cases ###############################

ro_725 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=725)
ro_725.plotCenterline(
save_plot_name="data/doc_examples/invalid_too_wide.png",
display_all_possible_paths=True,
show_plot=is_debug)

ro_250 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=250)
ro_250.plotCenterline(
save_plot_name="data/doc_examples/invalid_minor_polygon.png",
display_all_possible_paths=True,
show_plot=is_debug)

ro_1000 = centerline_width.riverCenterline(
csv_data="data/river_coords.csv", optional_cutoff=1000)
ro_1000.plotCenterline(
save_plot_name="data/doc_examples/invalid_major_polygon.png",
display_all_possible_paths=True,
show_plot=is_debug)

ro_10 = centerline_width.riverCenterline(csv_data="data/river_coords.csv",
optional_cutoff=5)
ro_10.plotCenterline(
ro_5.plotCenterline(
save_plot_name="data/doc_examples/invalid_too_small.png",
display_voronoi=True,
show_plot=is_debug)
Expand Down

0 comments on commit 31ecf61

Please sign in to comment.