Documentation / @interstellar-tools/maps / profile
Function: profile()
ts
function profile(
grid: GridInterface,
from: GridPositionInterface,
to: GridPositionInterface
): ProfilePointInterface[];Defined in: terrain/profile.ts:78
The height profile along a straight line on an elevation grid: heights about a cell apart, from gridValueBetween.
Where:
and are the rows and columns from start to end, and and the cell size is the number of steps: about one a cell; is sample 's distance along the line
Units
- Positions in grid coordinates; distances and heights in m.
Notes
- The first sample is at the start and the last at the end, so there are
. - The line is straight on the grid, a rhumb line on its map: over a few kilometres, the same as on the ground.
- The building block for line of sight, clearance under a flight path and the cost of a route.
Parameters
| Parameter | Type | Description |
|---|---|---|
grid | GridInterface | Elevation grid, heights in m. |
from | GridPositionInterface | Where it starts, in grid coordinates (on the grid). |
to | GridPositionInterface | Where it ends, in grid coordinates (on the grid). |
Returns
The samples, from the start.
Throws
- If a size, cell size or position is not finite.
- If the grid's parts don't fit together, or a position is off the grid.
Example
ts
// Across a crater, west to east through its middle
const points = profile(
grid,
{ row: 128, column: 0 },
{ row: 128, column: 255 }
);
profileStats(points).lowest; // the crater's floor, in m