geofabrics.bathymetry_estimation

This module contains classes associated with characterising channel geometry information.

Classes

Channel

A class to define a channel centre line from a digital network.

InterpolateMeasuredElevations

Interpolate measured river bed elevations. Requires LineStrings of

ChannelCharacteristics

A class to estimate the width, slope and other characteristics of a

Functions

node_centred_reach_cross_section(sampled_channel, ...)

Calculate cross_sections along a channel at the midpoint of each

Module Contents

geofabrics.bathymetry_estimation.node_centred_reach_cross_section(sampled_channel, transect_radius)

Calculate cross_sections along a channel at the midpoint of each segment.

Parameters:
  • sampled_channel (geopandas.GeoDataFrame) – The sampled channel defined as a single polyline. Any branches described separately.

  • transect_radius (float)

class geofabrics.bathymetry_estimation.Channel(channel, resolution, sampling_direction=1)

A class to define a channel centre line from a digital network.

Parameters:
  • channel (geopandas.GeoDataFrame)

  • resolution (float)

  • sampling_direction (int)

classmethod from_network(network_file, crs, starting_id, resolution, area_threshold, name_dict, sampling_direction=-1)

Create a channel object from a REC file.

Parameters:
  • network – Contains geometry and relational information between upstream and downstream reaches.

  • starting_id (int) – The ID of the reach to trace upstream from.

  • name_dict (dict) – The column names of the network.

  • area_threshold (float) – The minimum upstream area for upstream reaches to be included.

  • resolution (float) – The resolution of the upstream polyline trace to create from the network.

  • sampling_direction (int) – The direction to sample each reach polyline. 1 if each reach is defined downstream to upstream, -1 otherwise.

  • network_file (pathlib.Path)

  • crs (int)

get_parametric_spline_fit_points(k=3, spacing=None)

Return the spline smoothed polyline points created from two splines defining a parametric curve fit to points along the channel. The curve is resampled at even spacing once the splines are fit. If no spacing is provided the channel corner points are used, if a spacing is provided the channel corner points with sampling at the spacing are used.

Parameters:
  • k (int) – The polynomial degree. Should be off. 1 <= k <= 5.

  • spacing (float) – The spacing between sampled points along straight segments

get_parametric_spline_fit(k=3, spacing=None)

Return the spline smoothed polyline created from two splines defining a parametric curve fit to points along the channel. The curve is resampled at even spacing once the splines are fit. If no spacing is provided the channel corner points are used, if a spacing is provided the channel corner points with sampling at the spacing are used.

Parameters:
  • k (int) – The polynomial degree. Should be off. 1 <= k <= 5.

  • spacing (float) – The spacing between sampled points along straight segments

get_b_spline_fit(smoothing_multiplier=50, spacing=None)

Return the spline smoothed polyline created using a B-spline fit to corner points. If no spacing is provided the channel corner points are used, if a spacing is provided the channel corner points with sampling at the spacing are used.

Parameters:
  • smoothing_multiplier (float) – The polynomial degree. Should be off. 1 <= k <= 5.

  • spacing (float) – The spacing between sampled points along straight segments

Return type:

numpy.ndarray

get_b_spline_fit_points(smoothing_multiplier=50, spacing=None)

Return the spline smoothed polyline points created using a B-spline fit to corner points. If no spacing is provided the channel corner points are used, if a spacing is provided the channel corner points with sampling at the spacing are used.

Parameters:
  • smoothing_multiplier (float) – The polynomial degree. Should be off. 1 <= k <= 5.

  • spacing (float) – The spacing between sampled points along straight segments

Return type:

numpy.ndarray

get_channel_catchment(corridor_radius)

Create a catchment from the smooth channel and the specified radius.

Parameters:

corridor_radius (float) – The radius of the channel corridor. This will determine the width of the channel catchment.

Return type:

geopandas.GeoDataFrame

get_spaced_points(channel, spacing, sampling_direction)

Sample at the specified spacing along the entire line.

Parameters:
  • channel – A data frame with the geometry defining the channel centreline.

  • spacing (float) – The spacing between sampled points along straight segments

  • sample_direction – Are the reaches sampled in the same direction they are ordered. 1 if in the same direction, -1 if in the opposite direction.

  • sampling_direction (int)

Return type:

numpy.ndarray

get_spaced_points_with_corners(channel, spacing, sampling_direction)

Sample at the specified spacing along each straight segment.

Parameters:
  • channel – A data frame with the geometry defining the channel centreline.

  • spacing (float) – The spacing between sampled points along straight segments

  • sample_direction – Are the reaches sampled in the same direction they are ordered. 1 if in the same direction, -1 if in the opposite direction.

  • sampling_direction (int)

Return type:

numpy.ndarray

class geofabrics.bathymetry_estimation.InterpolateMeasuredElevations(riverbank_file, measured_sections_file, thalweg_file, cross_section_spacing, crs)

Interpolate measured river bed elevations. Requires LineStrings of riverbed elevations, and the LineStrings defining the left and right riverbank.

Parameters:
  • riverbank_file (pathlib.Path)

  • measured_sections_file (pathlib.Path)

  • thalweg_file (pathlib.Path)

  • cross_section_spacing (int)

  • crs (int)

check_valid_inputs()

Check expected entries in the input data

interpolate(samples_per_section, thalweg_centre=True)

Interpolate with equally spaced points along each cross section

Parameters:
  • number_samples – The number of samples along each cross section.

  • samples_per_section (int)

  • thalweg_centre (bool)

uniform_spacing(samples_per_section, cross_sections)

Interpolate with equally spaced points along each cross section

Parameters:
  • number_samples – The number of samples along each cross section.

  • samples_per_section (int)

thalweg_centred_spacing(samples_per_section, cross_sections)

Interpolate with equal number of equally spaced points on each side of the Thalweg.

Parameters:
  • number_samples – The number of samples along each cross section.

  • samples_per_section (int)

  • cross_sections (geopandas.GeoDataFrame)

thalweg_from_measured_centred_spacing(samples_per_section, cross_sections, measured_sections_exploded)

Interpolate with equal number of equally spaced points on each side of the Thalweg.

Parameters:
  • number_samples – The number of samples along each cross section.

  • samples_per_section (int)

  • cross_sections (geopandas.GeoDataFrame)

  • measured_sections_exploded (geopandas.GeoDataFrame)

class geofabrics.bathymetry_estimation.ChannelCharacteristics(gnd_dem, veg_dem, cross_section_spacing, resolution, debug=False)

A class to estimate the width, slope and other characteristics of a channel from a detailed DEM and a river network.

Parameters:
  • gnd_dem (xarray.Dataset)

  • veg_dem (xarray.Dataset)

  • cross_section_spacing (float)

  • resolution (float)

  • debug (bool)

property number_of_samples: int

Return the number of samples to take along cross_sections. This should be an odd number. Subtract 1 instead of adding to ensure within the generated DEM.

Return type:

int

calculate_min_z_start_i(min_z_search_radius)

Return the starting index of samples along each transect to begin looking for the minimum z.

Parameters:

min_z_search_radius – The distance to search from the centre.

Return type:

int

calculate_min_z_stop_i(min_z_search_radius)

Return the stopping index of samples along each transect to begin looking for the minimum z.

Parameters:

min_z_search_radius – The distance to search from the centre.

Return type:

int

property centre_index: int

Return the centre index for samples taken along a transect.

Return type:

int

sample_cross_sections(cross_sections, min_z_search_radius)

Return the elevations along the cross_section sampled at the sampling resolution. Also add the measured ‘min_z_centre’ values to the cross_sections.

Parameters:
  • cross_sections (geopandas.GeoDataFrame) – The cross_sections with geometry defined as polylines.

  • min_z_search_radius (float) – The distance to search from the centre.

fixed_thresholded_widths_from_centre_within_radius(cross_sections, cross_section_elevations, threshold, resolution, search_radius, min_channel_width)

Estimate width based on a thresbold of bank height above water level. Start in the centre and work out. Doesn’t detect banks until a value less than the threshold has been detected. Takes the widest channel within the radius.’

Parameters:
  • cross_sections (geopandas.GeoDataFrame) – The cross_sections with geometry defined as polylines.

  • cross_section_elevations (dict) – The sampled elevations along the cross_sections.

  • threshold (float) – The height above the water level to detect as a bank.

  • resolution (float) – The resolution to sample at.

  • search_radius (float) – The distance to search side to side from the centre index.

  • min_channel_width (float) – The minimum width of a ‘valid’ channel.

variable_thresholded_widths_from_centre_within_radius(cross_sections, cross_section_elevations, threshold, resolution, search_radius, maximum_threshold, min_channel_width=float)

Estimate width based on a thresbold of bank height above water level. Start in the centre and work out. Doesn’t detect banks until a value less than the threshold has been detected. Takes the widest channel within the radius.’

Parameters:
  • cross_sections (geopandas.GeoDataFrame) – The cross_sections with geometry defined as polylines.

  • cross_section_elevations (dict) – The sampled elevations along the cross_sections.

  • threshold (float) – The height above the water level to detect as a bank.

  • resolution (float) – The resolution to sample at.

  • search_radius (float) – The distance to search side to side from the centre index.

  • maximum_threshold (float) – The maximum amount to increase the bank height before stopping.

  • min_channel_width – The minimum width of a ‘valid’ channel.

fixed_threshold_width(gnd_samples, veg_samples, start_index, z_water, threshold, search_radius_index, min_channel_width)

Calculate the maximum width for a cross section given a fixed threshold - checking outwards, forwards and backwards within the search radius.

Parameters:
  • gnd_samples (numpy.ndarray) – The ground elevations for a single cross section.

  • veg_samples (numpy.ndarray) – The vegrtation elevations for the same cross section.

  • start_index (int) – The index to start the outward search from.

  • z_water (float) – The elevation of the water.

  • threshold (float) – The height above the water level to detect as a bank.

  • search_radius_index (int) – The distance in indices to search for the start of a channel away from the start_index

  • min_channel_width (float) – The minimum width of a ‘valid’ channel.

fixed_threshold_width_outwards(gnd_samples, veg_samples, start_index, z_water, threshold)

If the start_index is nan or less than the threshold, then cycle outwards until each side has gone above the threshold.

Parameters:
  • gnd_samples (numpy.ndarray) – The ground elevations for a single cross section.

  • veg_samples (numpy.ndarray) – The vegrtation elevations for the same cross section.

  • start_index (int) – The index to start the outward search from.

  • z_water (float) – The elevation of the water.

  • threshold (float) – The height above the water level to detect as a bank.

fixed_threshold_width_forwards(gnd_samples, veg_samples, start_index, z_water, threshold, stop_index)

Check for channels approaching forward.

Parameters:
  • gnd_samples (numpy.ndarray) – The ground elevations for a single cross section.

  • veg_samples (numpy.ndarray) – The vegrtation elevations for the same cross section.

  • start_index (int) – The index to start the outward search from.

  • z_water (float) – The elevation of the water.

  • threshold (float) – The height above the water level to detect as a bank.

  • stop_index (int) – The maximum index to search through

fixed_threshold_width_backwards(gnd_samples, veg_samples, start_index, z_water, threshold, stop_index)

Check for channels approaching backwards.

Parameters:
  • gnd_samples (numpy.ndarray) – The ground elevations for a single cross section.

  • veg_samples (numpy.ndarray) – The vegrtation elevations for the same cross section.

  • start_index (int) – The index to start the outward search from.

  • z_water (float) – The elevation of the water.

  • threshold (float) – The height above the water level to detect as a bank.

  • stop_index (int) – The minimum index to search through

align_channel(threshold, search_radius, min_channel_width, initial_channel, width_centre_smoothing_multiplier, cross_section_radius)

Estimate the channel centre from transect samples

Parameters:
  • threshold (float) – The height above the water level to detect as a bank.

  • search_radius (float) – The distance to search side to side from the centre index.

  • min_channel_width (float) – The minimum width of a ‘valid’ channel.

  • initial_channel (Channel) – The initial channel centreline to align.

  • width_centre_smoothing_multiplier (float) – The number of cross_sections to include in the downstream spline smoothing.

  • cross_section_radius (float) – The radius (or 1/2 length) of the cross sections along which to sample.

estimate_width_and_slope(aligned_channel, threshold, max_threshold, cross_section_radius, search_radius, min_channel_width)

Estimate the channel centre from transect samples

Parameters:
  • aligned_channel (geopandas.GeoDataFrame) – The channel centre line. Should be in the channel bed.

  • threshold (float) – The height height above the water level to detect as a bank.

  • max_threshold (float) – The maximum height above water level to detect as a bank (i.e. not a cliff)

  • cross_section_radius (float) – The radius (or 1/2 length) of the cross sections along which to sample.

  • search_radius (float) – The distance to search side to side from the centre index.

  • min_channel_width (float) – The minimum width of a ‘valid’ channel.