airbornegeo.split_into_segments

airbornegeo.split_into_segments#

split_into_segments(data, threshold, column_name, min_points_per_segment=0, angular_difference=False, segment_column=None, smoothing_window=None, absolute=False)[source]#

Split dataframe into segments where there is a gap in the supplied values greater than the threshold. Data are sorted by the column given by column_name which can be quantities such as time in seconds, cumulative distances, or aircraft heading or track. By default, a series of sequential segments names as integers starting at 1 will be returned. Alternatively, existing segments can be divided into new segments, via the column given by segment_column. The first sub-segment keeps the existing name and later ones have a suffix added (i.e., 210 -> 210 and 210_1) or the suffix will be incremented (210_1 -> 210_1 and 210_2). Names are returned as strings.

Parameters:
  • data (DataFrame) – _description_

  • threshold (float) – _description_, by default None

  • column_name (str) – Name of column supplying to data.

  • min_points_per_segment (int) – Segments with fewer points are giving a segment id of NaN, by default 0

  • angular_difference (bool) – if True, will interpret the data as degrees between 0 and 360, so the calculated differences are the shorted, for example the difference between 0 and 350 degrees will be -10 instead of 340.

  • segment_column (str | None) – Column of existing segment or line names to split within, by default None

  • smoothing_window (int | None) – Window size in number of data points for smoothing each difference after it’s been calculated, by default None. Note this averages the SIGNED difference, so it suppresses noise on an isolated break but cancels a change spread over many points. It is not a way to detect a sustained change such as a turn: use airbornegeo.split_at_turns for that.

  • absolute (bool) – if True, compare the magnitude of each difference against the threshold, so that decreases split the data as well as increases. Needed when the values can step either way, such as a track angle turning left or right, by default False

Returns:

A series with new segments identified with sequential integers starting with 1, or if segment_column is provided, string names extending the existing segment names (i.e. 210 -> 210 and 210_1).

Return type:

Series