Registry / serialization / utm
library0.9.0pypypi✓ verified 23d ago

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.

pip install utm
INSTALL
IMPORT
SIG · UTM
U
utm
serializationpythonv0.9.0
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from_latlon
from utm import from_latlon
import utm
to_latlon
from utm import to_latlon
import utm
OutOfRangeError
from utm import OutOfRangeError
import utm

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})")
Debug
Known issues
breakingPython 2.x and older Python 3.x versions (e.g., 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8) are no longer supported by recent versions of the `utm` library. The current version (0.8.1) requires Python >= 3.8.
fix
Ensure your environment uses Python 3.8 or newer. Upgrade your Python installation if necessary. If restricted to older Python, pin to an earlier `utm` version (e.g., `utm<0.8.0` for Python 3.7, `utm<0.7.0` for Python 3.4-3.6).
affects: 0.6.0 onwards, specifically 0.8.0 onwards for Python 3.8+.
gotchaWhen converting multiple latitude/longitude points to UTM using NumPy arrays with `utm.from_latlon`, the `ZONE_NUMBER` and `ZONE_LETTER` are determined solely by the *first* point in the input array. All subsequent points are then converted to this same determined UTM zone, even if they would naturally fall into a different zone. This can lead to incorrect results for geographically dispersed datasets.
fix
For datasets spanning multiple UTM zones, process points individually or group them by their correct UTM zone before conversion. Alternatively, for array processing where a single zone is desired (e.g., a convention like 'all Germany in Zone 32'), you might manually force the zone using the `force_zone_number` parameter if appropriate for your data.
affects: All versions.
gotchaThe `zone_letter` parameter in `utm.to_latlon` is technically optional. You can provide the `northern` boolean parameter instead (True for Northern Hemisphere, False for Southern Hemisphere). Neglecting this can lead to hemisphere ambiguity if `zone_letter` is omitted, or unnecessary complexity if `northern` is preferred.
fix
When converting from UTM to lat/lon, either provide the `zone_letter` (e.g., 'U' for Northern) or the `northern` boolean parameter (e.g., `northern=True`). Both achieve the same result but `northern` can be simpler if you only know the hemisphere.
affects: All versions.
gotchaAccuracy near the anti-meridian (longitude +/- 180 degrees) or when explicitly forcing UTM zones could have edge cases in older versions. While improvements have been made (e.g., in v0.6.0, v0.8.x), users dealing with coordinates close to these boundaries or using older library versions should validate their conversions carefully.
fix
Always use the latest stable version of the library. If working with data near the anti-meridian or enforcing zones, perform sanity checks on the output coordinates.
affects: Older versions (pre-0.8.0) were more susceptible. Users should be aware for all versions in edge cases.
gotchaWhile the `utm` library is pure Python and works without NumPy, conversions involving large arrays of coordinates are significantly slower without NumPy installed. The library automatically detects and utilizes NumPy if available.
fix
For performance-critical applications involving array processing, ensure `numpy` is installed in your environment (`pip install numpy`).
affects: All versions.
Upgrade
Version history
0.9.0latest on PyPI · released Jul 27, 2026
Audit
Dependencies
numpyoptionalOptional dependency for significantly improved performance when converting NumPy arrays of coordinates. The library functions correctly without it.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
utm — pip install utm · libregistry