Class: Utm

utm~Utm(zone, hemisphere, easting, northing, datumopt, convergenceopt, scaleopt)

UTM coordinates, with functions to parse them and convert them to LatLon points.

Constructor

new Utm(zone, hemisphere, easting, northing, datumopt, convergenceopt, scaleopt)

Creates a Utm coordinate object comprising zone, hemisphere, easting, northing on a given datum (normally WGS84).
Parameters:
Name Type Attributes Default Description
zone number UTM 6° longitudinal zone (1..60 covering 180°W..180°E).
hemisphere string N for northern hemisphere, S for southern hemisphere.
easting number Easting in metres from false easting (-500km from central meridian).
northing number Northing in metres from equator (N) or from false northing -10,000km (S).
datum LatLon.datums <optional>
WGS84 Datum UTM coordinate is based on.
convergence number <optional>
null Meridian convergence (bearing of grid north clockwise from true north), in degrees.
scale number <optional>
null Grid scale factor.
Source:
Throws:
Invalid UTM coordinate.
Type
TypeError
Example
import Utm from '/js/geodesy/utm.js';
  const utmCoord = new Utm(31, 'N', 448251, 5411932);

Methods

(static) parse(utmCoord, datumopt) → {Utm}

Parses string representation of UTM coordinate. A UTM coordinate comprises (space-separated) - zone - hemisphere - easting - northing.
Parameters:
Name Type Attributes Default Description
utmCoord string UTM coordinate (WGS 84).
datum Datum <optional>
WGS84 Datum coordinate is defined in (default WGS 84).
Source:
Throws:
Invalid UTM coordinate.
Type
TypeError
Returns:
Parsed UTM coordinate.
Type
Utm
Example
const utmCoord = Utm.parse('31 N 448251 5411932');
  // utmCoord: {zone: 31, hemisphere: 'N', easting: 448251, northing: 5411932 }

toLatLon(utmCoord) → {LatLon}

Converts UTM zone/easting/northing coordinate to latitude/longitude. Implements Karney’s method, using Krüger series to order n⁶, giving results accurate to 5nm for distances up to 3900km from the central meridian.
Parameters:
Name Type Description
utmCoord Utm UTM coordinate to be converted to latitude/longitude.
Source:
Returns:
Latitude/longitude of supplied grid reference.
Type
LatLon
Example
const grid = new Utm(31, 'N', 448251.795, 5411932.678);
  const latlong = grid.toLatLon(); // 48°51′29.52″N, 002°17′40.20″E

toString(digitsopt) → {string}

Returns a string representation of a UTM coordinate. To distinguish from MGRS grid zone designators, a space is left between the zone and the hemisphere. Note that UTM coordinates get rounded, not truncated (unlike MGRS grid references).
Parameters:
Name Type Attributes Default Description
digits number <optional>
0 Number of digits to appear after the decimal point (3 ≡ mm).
Source:
Returns:
A string representation of the coordinate.
Type
string
Example
const utm = new Utm('31', 'N', 448251, 5411932).toString(4);  // 31 N 448251.0000 5411932.0000