Skip to content

Documentation / @interstellar-tools/maps / profileStats

Function: profileStats() ​

ts
function profileStats(
  points: readonly ProfilePointInterface[]
): ProfileStatsInterface;

Defined in: terrain/profile.ts:194

A profile's figures: its length, how much it rises from start to end, its highest and lowest points, and its steepest grade.

gradek=arctan⁡|hk−hk−1|dk−dk−1

Notes

  • The grade is between neighbouring samples, about a cell apart from profile: it's the slope along the line, which is at most the ground's own slope there.
  • Samples with a NaN height are left out: of the rise, which runs from the first sample with a height to the last, of the highest and lowest, and of the grades next to them. With none, the rise, highest and lowest are NaN, and the grade 0.

Parameters ​

ParameterTypeDescription
pointsreadonly ProfilePointInterface[]The profile, as profile or pathProfile give it (at least one sample).

Returns ​

ProfileStatsInterface

Its length, rise, highest and lowest heights, and steepest grade.

Throws ​

If there are no samples.

Example ​

ts
profileStats([
  { distance: 0, height: 5 },
  { distance: 10, height: 15 },
  { distance: 20, height: 12 }
]); // length 20, rise 7, highest 15, lowest 5, steepestGrade π/4

See ​

profile