Centerline-width

Latest version: v1.6.0

Safety actively analyzes 623871 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 4

1.6.0

Update to Back End for plotCenterlineWidth()

Update accounts for the curvature of the Earth when calculating the slope for width with `plotCenterlineWidth()`

Previously, slopes were calculated based on `transect_span_distance` without accounting for the curvature of the planet. Updated functionality now accounts for the curvature of the planet (defined by `ellipsoid`, defaults to `WGS84`). Adjusts positions where width lines intersect banks.

Previous (left) and updated (right) places where width lines intersect bank

![original_left](https://github.com/cyschneck/centerline-width/assets/22159116/c4f3cd43-952f-40af-91a0-331235d13cf6)

Area of River
Return the area contained within the polygon generated the left and right bank latitude/longitudes

river_object.riverArea

Area returned in kilometers^2
python
import centerline_width
river_object = centerline_width.riverCenterline(csv_data="data/river_coords.csv")
river_area = river_object.riverArea


Code Coverage
New code coverage and testing to track back end of repo

Expanding pytests to coverage existing functionality for centerline and widths (~93%) error handling and expected outputs

Backwards Compatibility Conflicts

`convertColumnsToCSV()` argument `flipBankDirection` changed to `flip_direction` to be consistent with snake-case variable naming conventions among other functions

Drops active support for Python 3.9 in support of [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html)

_Bug fixes and README.md edits_

_Pytests: Tests for Python 3.10, 3.11, 3.12 against Ubuntu, macOS, Windows_

1.5.0

New options: show_plot

New option `show_plot` and the option to use relative paths. New options are optional and backwards compatible, so there should be no impact on existing scripts.

**show_plot**

New option in `plotCenterline()` and `plotCenterlineWidth()`

New option to not show a newly generated plot. The plot will still save if `save_plot` is still in use. Useful when running `centerline-width` as part of a loop to save multiple plots without having to close each plot after it is generated. `show_plot=False` is the same as not using plt.show() in Matplotlib.

**Relative Paths**

New back-end option to use a relative instead of absolute path when `convertColumnsToCSV()`


relative path: file_path = "../../B/aaa.txt"
absolute path: file_path = "test/testing/B/aaa.txt"


**Python 3.12 Support**

Expanded testing suite and verify support with Python 3.12. Currently supporting Python 3.9, 3.10, 3.11, 3.12

**Developer Environment**

New conda environment file `environment.yml` for working with or testing against the `centerline-width`

_Bug fixes and README.md edits_

_Pytests: 233 tests for Python 3.9, 3.10, 3.11, 3.12 against Ubuntu, macOS, Windows_

1.4.1

New Options: `equal_axis`, `transect_slope`, `dark_mode`
All new options are optional and backwards compatible so there should be no impact to existing scripts

equal_axis

Closes: 4 where perpendicular width lines do not appear perpendicular

equal_axis will set the x and y axis of the plot to be equal. Useful to show the perpendicular width lines as perpendicular since it can appear distorted by default in Matplotlib

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

transect_slope
The width lines are generated as perpendicular to the slopes of the points across `transect_span_distance`

By default, `transect_slope="Average"` where the width lines are perpendicular to the average slopes of the across span distance. For example: `[A, B, C, D] = avg( slope([A, B]) + slope([B, C]) + slope([C+D]) )`

Optionally, if `transect_slope="Direct"` then the width lines will be perpendicular to slope of the first and last point. For example: `[A, B, C, D] = slope([A, D])` to avoid being susceptible to rapid small changes along the centerline

![transect_span_distance](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/slope_description.png)
| transect_slope="Average" | transect_slope="Direct" |
| ------------- | ------------- |
| ![river_transect_avg+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_transect_avg.png) | ![river_transect_direct+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_transect_direct.png) |

dark_mode

New smart dark mode option when generating Matplotlib (for long suffering eyes)

| dark_mode=False | dark_mode=True |
| ------------- | ------------- |
| ![river_white+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_width_dark_mode_false.png) | ![river_black+png](https://raw.githubusercontent.com/cyschneck/centerline-width/main/data/doc_examples/river_coords_width_dark_mode_true.png)|

Additional Changes:
- `transect_span_distance` minimum has been change from 3 to 2 (to measure a single slope)

Note: Re-release of 1.4.0 with hot fix for PyPi package

__Bug fixes and README.md edits__
__Pytests: 229 tests for Python 3.9, 3.10, 3.11__

1.3.0

New Option for riverWidthFromCenterline: coordinate_reference
New option for `riverWidthFromCenterlinen()` to reference a width line
- Two options: `Centerline` and `Banks`
- By default, `coordinate_reference="Centerline"` where width lines are referenced in respect to the centerline coordinate that it intersects
- New option, `coordinate_reference="Banks"` where width lines are referenced in respect to the right and left banks that it intersects (resolves: 1)
- No changes to existing behavior and function is backwards compatible

More details: [riverWidthFromCenterline](https://github.com/cyschneck/centerline-width#return-width-of-river)

Bug fix: centerlineLength()
Length was being calculated incorrectly as the pairs of coordinates being calculated were not correctly updating (A->B + A->C, fix: A->B + B->C)

Thanks to mthaddon for identifying the bug and PR fix 2 🎉

_Bug fixes and README.md edits_

_Pytests: 211 tests_

1.2.1

Bug Fix: riverWidthFromCenterline()
Fix allows for width from centerline to be saved to a csv
- Bug introduced when `coordinate_type` renamed to `coordinate_unit`
- Backend updated: new script saveOutput.py
- saveOutput.py: saveCenterlineCSV() and saveCenterlineMAT() moved to a separate script

Inclusive of all points
`left_bank_relative_coordinates` now inclusive for all points
- Includes the first point of the left bank to be a Relative Distance of (0,0)

_Bug fixes and README.md edits_

_Pytests: 205 tests_

1.2.0

coordinate_type renamed to coordinate_unit: "Relative Distance" vs. "Decimal Degrees"
Original argument renamed from `coordinate_type` to `coordinate_unit`

Change can impact backward functionality in:

- plotCenterline()
- plotCenterlineWidth()
- saveCenterlineCSV()
- saveCenterlineMAT()

Fix to `riverWidthFromCenterline()`
Returns accurate coordinates and width size when using `coordinate_unit = "Relative Distance"`

_Bug fixes and README.md edits_

_Pytests: 205 tests_

Page 1 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.