Skip to content

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.

x=x0+cΔx,y=y0−rΔy

Units

  • Inputs: row and column in 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 ​

ParameterTypeDescription
transformGeoTransformInterfaceWhere the grid lies on the map.
positionGridPositionInterfaceThe row and column, fractional (each finite).

Returns ​

ProjectedPointInterface

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

See ​