environmentaltools.spatial.normal_profiles

environmentaltools.spatial.normal_profiles(topobat, info, n_points=1000)[source]

Extract normal profiles from spatial topography/bathymetry data.

Interpolates elevation/depth values along multiple profile lines defined by start and end coordinates. Each profile is sampled at equally-spaced points along the line connecting its endpoints.

Parameters:
  • topobat (pd.DataFrame) – Topography/bathymetry data containing columns ‘x’, ‘y’, and ‘z’. ‘z’ represents elevation (positive above datum) or depth (negative below).

  • info (dict) – Dictionary defining profile locations with keys: - ‘x’: list of [x_start, x_end] coordinate pairs for each profile - ‘y’: list of [y_start, y_end] coordinate pairs for each profile Each pair defines a profile line endpoint.

  • n_points (int, optional) – Number of equally-spaced points to sample along each profile. Default is 1000. Higher values provide finer resolution but increase computation time.

Returns:

  • x (list of np.ndarray) – X coordinates along each profile (n_points per profile)

  • y (list of np.ndarray) – Y coordinates along each profile (n_points per profile)

  • z (list of np.ndarray) – Interpolated elevation/depth values along each profile. NaN values indicate locations outside the convex hull of input data.

Examples

>>> import pandas as pd
>>> import numpy as np
>>> # Create sample bathymetry data
>>> topobat = pd.DataFrame({
...     'x': [0, 10, 20, 0, 10, 20],
...     'y': [0, 0, 0, 10, 10, 10],
...     'z': [-5, -10, -15, 0, -2, -5]
... })
>>> # Define two profile lines
>>> info = {'x': [[0, 20], [5, 15]], 'y': [[0, 10], [0, 10]]}
>>> x, y, z = normal_profiles(topobat, info, n_points=500)
>>> print(f"Number of profiles: {len(x)}, points per profile: {len(x[0])}")
Number of profiles: 2, points per profile: 500