Documentation / @interstellar-tools/maps / cellToMap
Function: cellToMap()
ts
function cellToMap(
transform: GeoTransformInterface,
position: GridPositionInterface
): ProjectedPointInterface;Defined in: terrain/geotransform.ts:78
Place a grid position on a map: the map coordinates of a row and column, through the grid's GeoTransformInterface.
Units
- Inputs:
rowandcolumnin cells, fractional; the transform in m. - Output:
{ x, y }on the map in m.
Notes
- Whole rows and columns are cells' centres; ±0.5 are their edges.
- A position off the grid is placed too, by the same transform.
- The inverse is mapToCell. A projection's inverse, such as inverseMercator, goes on to latitude and longitude.
Parameters
| Parameter | Type | Description |
|---|---|---|
transform | GeoTransformInterface | Where the grid lies on the map. |
position | GridPositionInterface | The row and column, fractional (each finite). |
Returns
The map position, in m.
Throws
- If the transform or the position is not finite.
- If a cell size is
<= 0.
Example
ts
// Where is the highest cell of an elevation tile?
const transform = tileGeoTransform(tile, 256, 256, 6378137);
const { x, y } = cellToMap(transform, { row: 113, column: 128 });
inverseMercator(x, y, 6378137); // { phi, lambda } in radians