Profile¶
Data class¶
bathy.Profile
dataclass
¶
Single bathymetric profile.
Attributes:
| Name | Type | Description |
|---|---|---|
distances |
ndarray
|
Distances along profile (m) |
elevations |
ndarray
|
Elevation values along profile (m) |
start_x, start_y |
float
|
Starting coordinates (lon/lat or easting/northing) |
end_x, end_y |
float
|
Ending coordinates (lon/lat or easting/northing) |
name |
(str, optional)
|
Profile name |
crs |
(CRS, optional)
|
Coordinate reference system |
metadata |
dict
|
Additional metadata (includes path_xs, path_ys for plotting) |
Examples:
>>> prof = extract_profile(data, start=(-9.5, 52.0), end=(-5.5, 52.0))
>>> prof = extract_profile(
... data, start=(-9.5, 52.0), end=(-5.5, 52.0), point_spacing=1000.0
... )
Source code in src/bathy/profile.py
Construction¶
bathy.extract_profile(data, start, end, num_points=None, point_spacing=None, name=None, metadata=None, method='nearest')
¶
Create a bathymetric profile between two points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
start
|
tuple[float, float]
|
Starting coordinates (lon, lat) or (easting, northing) |
required |
end
|
tuple[float, float]
|
Ending coordinates (lon, lat) or (easting, northing) |
required |
num_points
|
int
|
Number of points along profile. Cannot be used with point_spacing. Default: 100 if neither num_points nor point_spacing is specified. |
None
|
point_spacing
|
float
|
Spacing between points in metres. Cannot be used with num_points. |
None
|
name
|
str
|
Name for this profile |
None
|
metadata
|
dict
|
Additional metadata |
None
|
method
|
str
|
Interpolation method for sampling the grid: |
'nearest'
|
Returns:
| Type | Description |
|---|---|
Profile
|
|
Examples:
>>> prof = extract_profile(data, start=(-9.5, 52.0), end=(-5.5, 52.0))
>>> prof = extract_profile(
... data, start=(-9.5, 52.0), end=(-5.5, 52.0), point_spacing=1000.0
... )
Source code in src/bathy/profile.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
bathy.profile_from_coordinates(data, coordinates, point_spacing=None, name=None, metadata=None, method='nearest')
¶
Create a Profile from a list of (x, y) coordinates.
By default, samples only at the given vertices. Use point_spacing
to interpolate along each segment at regular intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
coordinates
|
list[tuple[float, float]]
|
List of (x, y) coordinate pairs defining the path |
required |
point_spacing
|
float
|
Spacing between sample points in metres. When provided, each segment is interpolated at this interval. |
None
|
name
|
str
|
Name for this profile |
None
|
metadata
|
dict
|
Additional metadata |
None
|
method
|
str
|
Interpolation method for sampling the grid: |
'nearest'
|
Returns:
| Type | Description |
|---|---|
Profile
|
|
Examples:
>>> coords = [(-10.0, 50.0), (-9.5, 50.5), (-9.0, 51.0)]
>>> prof = profile_from_coordinates(data, coords, name="Custom Path")
>>> prof = profile_from_coordinates(data, coords, point_spacing=1000.0)
Source code in src/bathy/profile.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | |
bathy.cross_sections(data, profile, interval_m, section_width_m, num_points=None, point_spacing=None, method='nearest')
¶
Create perpendicular cross-sections along a profile at regular intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
profile
|
Profile
|
The profile along which to create cross-sections |
required |
interval_m
|
float
|
Spacing between cross-sections in metres (must be positive) |
required |
section_width_m
|
float
|
Total width of each cross-section in metres (must be positive) |
required |
num_points
|
int
|
Number of points along each cross-section |
None
|
point_spacing
|
float
|
Spacing between points in metres along cross-sections |
None
|
method
|
str
|
Interpolation method (default |
'nearest'
|
Returns:
| Type | Description |
|---|---|
list[Profile]
|
|
Examples:
>>> prof = extract_profile(data, start=(-9.5, 52.0), end=(-5.5, 54.0))
>>> sections = cross_sections(data, prof, interval_m=10000, section_width_m=20000)
Source code in src/bathy/profile.py
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | |
bathy.profiles_from_file(data, path, id_column=None, point_spacing=None, method='nearest')
¶
Create profiles from linestring features in a vector file.
Accepts any format supported by GeoPandas (Shapefile, GeoPackage, GeoJSON, etc.).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
path
|
str or Path
|
Path to vector file containing LineString or MultiLineString features |
required |
id_column
|
str
|
Column name to use for profile naming |
None
|
point_spacing
|
float
|
Spacing between sample points in metres. When provided, each segment is interpolated along the geodesic at this interval. |
None
|
method
|
str
|
Interpolation method (default |
'nearest'
|
Returns:
| Type | Description |
|---|---|
list[Profile]
|
|
Examples:
Source code in src/bathy/profile.py
bathy.profiles_from_gdf(data, gdf, id_column=None, point_spacing=None, method='nearest')
¶
Create profiles from LineString features in a GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
gdf
|
GeoDataFrame
|
GeoDataFrame with LineString or MultiLineString geometries |
required |
id_column
|
str
|
Column to use for profile names |
None
|
point_spacing
|
float
|
Spacing between sample points in metres. When provided, each segment is interpolated along the geodesic at this interval. |
None
|
method
|
str
|
Interpolation method (default |
'nearest'
|
Returns:
| Type | Description |
|---|---|
list[Profile]
|
|
Examples:
Source code in src/bathy/profile.py
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | |
Analysis¶
bathy.profile_stats(profile)
¶
Calculate statistics for the profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with statistics |
Source code in src/bathy/profile.py
bathy.max_depth(profile)
¶
Find the maximum depth point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
(distance_m, depth_m) of the deepest point |
Source code in src/bathy/profile.py
bathy.gradient(profile)
¶
Calculate the slope along the profile in degrees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Slope in degrees |
Source code in src/bathy/profile.py
bathy.concavity_index(profile)
¶
Calculate Normalized Concavity Index (NCI) of the profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
Returns:
| Type | Description |
|---|---|
float
|
Positive = concave, negative = convex, near zero = straight |
Examples:
Source code in src/bathy/profile.py
bathy.knickpoints(profile, threshold=None, smooth=None)
¶
Identify knickpoints (abrupt slope changes) along the profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
threshold
|
float
|
Minimum rate of slope change (degrees/m). Defaults to 2 std above mean. |
None
|
smooth
|
float
|
Gaussian smoothing sigma before detection. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Knickpoints with columns: distance_m, depth_m, slope_break_deg |
Source code in src/bathy/profile.py
bathy.get_canyons(profile, prominence=None, smooth=None)
¶
Identify canyon features in the profile.
Canyons are identified as prominent troughs bounded by peaks on both sides. The shoulder elevation is the lower of the two bounding peaks; width, depth and cross-sectional area are all measured relative to that level. Troughs without a detected peak on each side are skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Profile
|
|
required |
prominence
|
float
|
Minimum prominence (m) for canyon detection. Defaults to 10% of range. |
None
|
smooth
|
float
|
Gaussian smoothing sigma before detection. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Canyon measurements (distances in m, area in m²). |
Source code in src/bathy/profile.py
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | |
bathy.compare_stats(profiles)
¶
Compare statistics across multiple profiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
list[Profile]
|
|
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Statistics for all profiles in wide format (profiles as columns) |
Examples:
>>> from bathy.profile import compare_stats
>>> prof1 = extract_profile(data, start=(-8, 52), end=(-2, 58), name="Profile 1")
>>> prof2 = extract_profile(data, start=(-8, 53), end=(-2, 59), name="Profile 2")
>>> df = compare_stats([prof1, prof2])
Source code in src/bathy/profile.py
bathy.to_gdf(profiles)
¶
Export one or more profiles as a GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
Profile or list[Profile]
|
|
required |
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
One row per profile with LineString geometry and key statistics. |
Examples:
>>> from bathy.profile import to_gdf
>>> gdf = to_gdf(prof)
>>> gdf = to_gdf([prof1, prof2])
>>> gdf.to_file("profiles.gpkg", driver="GPKG")