shapelib.tools.lines package#

Subpackages#

Submodules#

shapelib.tools.lines.distance module#

shapelib.tools.lines.distance.estimate_line_spacing(lines, sample=0.1, min_samples=30, seed=None)[source]#

Estimate the spacing between parallel planting lines (e.g. rows every 1.5 m or 2.4 m).

Samples a few lines, measures each one’s center-to-nearest-line distance, and returns the median (robust to far-apart edge/stray lines). Assumes lines are roughly parallel with uniform spacing, so a small sample suffices.

Parameters:
  • lines (GeoDataFrame) – Line geometries in a metric CRS (e.g. UTM).

  • sample (float) – Fraction of lines to sample if <= 1, else an absolute count.

  • min_samples (int) – Minimum lines to sample, clamped to the total.

  • seed (int | None) – Seed for reproducible sampling.

Returns:

Estimated spacing in CRS units (meters for UTM).

Return type:

float