Skip to content

Commit

Permalink
return area at m^2
Browse files Browse the repository at this point in the history
  • Loading branch information
cyschneck committed Sep 21, 2024
1 parent 4229c7e commit efc73bf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ The red pins represent the equal distance centerline coordinates produced by cen
* centerline_length (float): Length of the centerline of the river (in km)
* right_bank_length (float): Length of the right bank of the river (in km)
* left_bank_length (float): Length of the left bank of the river (in km)
* area (float): Area contained within river bank polygon (in km^2)
* area (float): Area contained within river bank polygon (in m^2)
* sinuosity (float): Sinuosity of the river based on evenly spaced centerline coordinates
* centerline_voronoi_relative (list of tuples): List of the relative distance coordinates of the centerline generated by Voronoi diagrams
* centerline_equal_distance_relative (list of tuples): List of the relative distance coordinates of the centerline generated by equal distances between coordinates from the Voronoi diagrams
Expand Down Expand Up @@ -397,13 +397,13 @@ Return the area contained within the polygon generated the left and right bank l
```
river_object.area
```
Area returned in kilometers^2
Area returned in meters^2
```python
import centerline_width
river_object = centerline_width.CenterlineWidth(csv_data="data/river_coords.csv")
river_area = river_object.area
```
The area of the river returns `334.0398585246558` km^2
The area of the river returns `3132.0671725985594` m^2

### Total Sinuosity of River
Return the total sinuosity of the river
Expand Down
8 changes: 4 additions & 4 deletions centerline_width/pytests/test_verifyRiverCenterlineClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_CenterlineWidth_default():
0.09705816897006408)
assert river_class_example.left_bank_length == pytest.approx(
0.10570962276643736)
assert river_class_example.area == pytest.approx(11.4030195647527)
assert river_class_example.area == pytest.approx(11403.0195647527)
assert river_class_example.starting_node == pytest.approx(
(-92.86781887353752, 30.03824341873465))
assert river_class_example.ending_node == pytest.approx(
Expand Down Expand Up @@ -722,7 +722,7 @@ def test_CenterlineWidth_futureWarning_functionName():
0.09705816897006408)
assert river_class_example.left_bank_length == pytest.approx(
0.10570962276643736)
assert river_class_example.area == pytest.approx(11.4030195647527)
assert river_class_example.area == pytest.approx(11403.0195647527)
assert river_class_example.starting_node == pytest.approx(
(-92.86781887353752, 30.03824341873465))
assert river_class_example.ending_node == pytest.approx(
Expand Down Expand Up @@ -1124,7 +1124,7 @@ def test_CenterlineWidth_futureWarning_variableName():
0.0291159670403472)
assert river_class_example.left_bank_length == pytest.approx(
0.03091855487702919)
assert river_class_example.area == pytest.approx(3.1320671725985596)
assert river_class_example.area == pytest.approx(3132.0671725985594)
assert river_class_example.starting_node == pytest.approx(
(-92.86792843577895, 30.037755468515407))
assert river_class_example.ending_node == pytest.approx(
Expand Down Expand Up @@ -2223,7 +2223,7 @@ def test_CenterlineWidth_interpolateTrue():
0.09705816897212159)
assert river_class_example.left_bank_length == pytest.approx(
0.1057096227682203)
assert river_class_example.area == pytest.approx(11.403019517285152)
assert river_class_example.area == pytest.approx(11403.019517285153)
assert river_class_example.starting_node == pytest.approx(
(-92.86782125207236, 30.03827120587997))
assert river_class_example.ending_node == pytest.approx(
Expand Down
2 changes: 1 addition & 1 deletion centerline_width/pytests/test_verifyRiverFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_riverFeatures_leftBankLength():


def test_riverFeatures_area():
assert river_class_example.area == pytest.approx(11.4030195647527)
assert river_class_example.area == pytest.approx(11403.0195647527)


def test_riverFeatures_riverSinuosity():
Expand Down
4 changes: 2 additions & 2 deletions centerline_width/riverFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@

def _calculate_river_area(bank_polygon=None,
ellipsoid: str = "WGS84") -> float:
# Return the area contained within the river polygon (km^2)
# Return the area contained within the river polygon (m^2)
if bank_polygon is None:
return 0
geodesic = Geod(ellps=ellipsoid)
river_area, river_perimeter = geodesic.geometry_area_perimeter(
bank_polygon)
return abs(river_area) / 1000 # km
return abs(river_area) # m^2


def _centerline_length(centerline_coordinates: list = None,
Expand Down
3 changes: 2 additions & 1 deletion river_centerline_width_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@
print(f"ellipsoid = {river.ellipsoid}")
print(river.right_bank_relative_coordinates)
print(river.left_bank_relative_coordinates)
print(f"area = {river.area} km^2")
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"
Expand Down
2 changes: 1 addition & 1 deletion river_centerline_width_example_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
print(f"ellipsoid = {river.ellipsoid}")
print(river.right_bank_relative_coordinates)
print(river.left_bank_relative_coordinates)
print(f"area = {river.area} km^2")
print(f"area = {river.area} m^2")
print(f"sinuosity = {river.sinuosity}")
incremental_sinuosity = river.incremental_sinuosity(incremental_points=215,
save_to_csv=None)
Expand Down

0 comments on commit efc73bf

Please sign in to comment.