UTM-WGS84 Converter

0.8.1 · active · verified Sun Apr 12

The `utm` library provides bidirectional conversion between Universal Transverse Mercator (UTM) coordinates and WGS84 latitude/longitude pairs for Python. It is a lightweight, pure Python package, optionally leveraging NumPy for enhanced performance with array-based operations. The library is actively maintained, with regular releases addressing accuracy improvements and Python version compatibility.

Warnings

Install

Imports

Quickstart

Demonstrates converting WGS84 latitude/longitude to UTM coordinates and vice-versa using `utm.from_latlon` and `utm.to_latlon`. It also shows the use of the `northern` parameter as an alternative to `zone_letter` for `to_latlon`.

import utm

# Example 1: Latitude/Longitude to UTM
latitude = 51.2
longitude = 7.5
easting, northing, zone_number, zone_letter = utm.from_latlon(latitude, longitude)
print(f"Lat/Lon ({latitude}, {longitude}) -> UTM: ({easting:.2f}, {northing:.2f}, {zone_number}{zone_letter})")

# Example 2: UTM to Latitude/Longitude
eutm_easting = 395201.31
utm_northing = 5673135.24
utm_zone_number = 32
utm_zone_letter = 'U'

lat, lon = utm.to_latlon(utm_easting, utm_northing, utm_zone_number, utm_zone_letter)
print(f"UTM ({utm_easting:.2f}, {utm_northing:.2f}, {utm_zone_number}{utm_zone_letter}) -> Lat/Lon: ({lat:.6f}, {lon:.6f})")

# Example with 'northern' parameter (alternative to zone_letter for to_latlon)
lat_northern, lon_northern = utm.to_latlon(utm_easting, utm_northing, utm_zone_number, northern=True)
print(f"UTM (using northern=True) -> Lat/Lon: ({lat_northern:.6f}, {lon_northern:.6f})")

view raw JSON →