Skip to content

Commit

Permalink
v0.2.4 release with user warnings for interpolate_n_centerpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
cyschneck committed Jun 3, 2023
1 parent bd18a90 commit c129543
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ centerline_width.riverCenterline(csv_data=None,
* [OPTIONAL] optional_cutoff (int): Include only the first x number of the data to chart (useful for debugging)
* [OPTIONAL] interpolate_data (bool): Interpolate between existing data by adding additional points
* [OPTIONAL] interpolate_n (int): Number of additional points to add between existing data, defaults to 5 (note: larger numbers will take exponentially longer to run, recommends less than 15)
* [OPTIONAL] interpolate_n_centerpoints (int): Number of points used to interpolate the Voronoi centerline, defaults to the the length of the dataframe (df_len)
* [OPTIONAL] interpolate_n_centerpoints (int): Number of points used to interpolate the Voronoi centerline, defaults to the the length of the data frame (df_len)

**Solutions for sparse data:**

Expand All @@ -190,7 +190,7 @@ centerline_width.riverCenterline(csv_data=None,
* river_name (string): name of object, set to the csv_data string
* left_bank_coordinates (list of tuples): list of coordinates of the left bank generated from the csv file (`[(x, y), (x, y)]`)
* right_bank_coordinates (list of tuples) list of coordinates of the right bank generated from the csv file (`[(x, y), (x, y)]`)
* df_len (int): Length of the dataframe of the csv data (spliced by the optional_cutoff)
* df_len (int): Length of the data frame of the csv data (spliced by the optional_cutoff)
* bank_polygon (Shapley Polygon): Multi-sided polygon generated to encapsulate river bank (used to define an inside and an outside of the river)
* top_bank (Shapley Linestring): Linestring that represents the top of the river/polygon
* bottom_bank (Shapley Linestring): Linestring that represents the bottom of the river/polygon
Expand All @@ -201,7 +201,7 @@ centerline_width.riverCenterline(csv_data=None,
* y_voronoi_ridge_point (list of tuples): Y position on Voronoi ridge (starting Longitude position to ending Longitude position)
* interpolate_data (bool): if interpolating between existing data, defaults to False
* interpolate_n (int): specifies how many additional points will be added between points along the river bank when interpolating data, defaults to 5
* interpolate_n_centerpoints (int): specifies how many points will be used to interpolate the Voronoi centerline, defaults to the length of the dataframe (df_len)
* interpolate_n_centerpoints (int): specifies how many points will be used to interpolate the Voronoi centerline, defaults to the length of the data frame (df_len)


```python
Expand Down Expand Up @@ -460,13 +460,13 @@ The smoothed centerline can end up lying outside the river if the centerline dat

Example Error: `WARNING: Partially invalid smoothed centerline due to sparse centerline data (6 points lie outside the polygon), fix recommendation: rerun riverCenterline to create river object with interpolate_n_centerpoints set to 62+`

By default, `interpolate_n_centerpoints` is set to None and not additional points will be added between the existing points along the centerline. By adding additional points between the existing centerline, the smoothed centerline can be fixed. Set river object created by `centerline_width.riverCenterline` to `interpolate_n_centerpoints=65` to fix for centerline coordinates that lie outside the polyogon
By default, `interpolate_n_centerpoints` is set to None and not additional points will be added between the existing points along the centerline. By adding additional points between the existing centerline, the smoothed centerline can be fixed to stay within the polygon. This fix is set by creating a river object, `centerline_width.riverCenterline`, with `interpolate_n_centerpoints=65` (with the recommended 62+) to fix for centerline coordinates that lie outside the polyogon

`interpolate_n_centerpoints = None` does not interpolate data points, so the size will be set to the number of fixed points when creating the evenly spaced coordinates (equal to the size of the dataframe)
`interpolate_n_centerpoints = None` does not interpolate data points, so the size will be set to the number of fixed points when creating the evenly spaced coordinates (equal to the size of the data frame)

| interpolate_n_centerpoints = None | interpolate_n_centerpoints = 65 |
| ------------- | ------------- |
| [![example+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/invalid_smoothed_centerline.png) | ![river_centerline+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/invalid_smoothed_centerline_fixed.png) |
| ![example+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/invalid_smoothed_centerline.png) | ![river_centerline+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/invalid_smoothed_centerline_fixed.png) |


### Fix Gaps and Jagged Centerlines
Expand All @@ -483,8 +483,6 @@ river_object = centerline_width.riverCenterline(csv_data="data/river_coords.csv"

The amount of additional points added by interpolating can be adjusted with `interpolate_n`, but defaults to add 5 additional points between values



## Developer Notes: Tech Debt and Bug Fixes
* Fix legend overlapping on graph, replace doc_examples that have an overlapping
* Verify that smoothing filter option does not produce a line that goes outside of the polygon
Expand Down
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.3"
VERSION="0.2.4"
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 c129543

Please sign in to comment.