{"id":4841,"library":"utm","title":"UTM-WGS84 Converter","description":"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.","status":"active","version":"0.8.1","language":"en","source_language":"en","source_url":"https://github.com/Turbo87/utm","tags":["geospatial","utm","wgs84","coordinates","conversion"],"install":[{"cmd":"pip install utm","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Optional dependency for significantly improved performance when converting NumPy arrays of coordinates. The library functions correctly without it.","package":"numpy","optional":true}],"imports":[{"note":"Main function to convert latitude/longitude to UTM.","symbol":"from_latlon","correct":"import utm\nutm.from_latlon(...)"},{"note":"Main function to convert UTM to latitude/longitude.","symbol":"to_latlon","correct":"import utm\nutm.to_latlon(...)"}],"quickstart":{"code":"import utm\n\n# Example 1: Latitude/Longitude to UTM\nlatitude = 51.2\nlongitude = 7.5\neasting, northing, zone_number, zone_letter = utm.from_latlon(latitude, longitude)\nprint(f\"Lat/Lon ({latitude}, {longitude}) -> UTM: ({easting:.2f}, {northing:.2f}, {zone_number}{zone_letter})\")\n\n# Example 2: UTM to Latitude/Longitude\neutm_easting = 395201.31\nutm_northing = 5673135.24\nutm_zone_number = 32\nutm_zone_letter = 'U'\n\nlat, lon = utm.to_latlon(utm_easting, utm_northing, utm_zone_number, utm_zone_letter)\nprint(f\"UTM ({utm_easting:.2f}, {utm_northing:.2f}, {utm_zone_number}{utm_zone_letter}) -> Lat/Lon: ({lat:.6f}, {lon:.6f})\")\n\n# Example with 'northern' parameter (alternative to zone_letter for to_latlon)\nlat_northern, lon_northern = utm.to_latlon(utm_easting, utm_northing, utm_zone_number, northern=True)\nprint(f\"UTM (using northern=True) -> Lat/Lon: ({lat_northern:.6f}, {lon_northern:.6f})\")","lang":"python","description":"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`."},"warnings":[{"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).","message":"Python 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.","severity":"breaking","affected_versions":"0.6.0 onwards, specifically 0.8.0 onwards for Python 3.8+."},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions."},{"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.","message":"The `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.","severity":"gotcha","affected_versions":"All versions."},{"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.","message":"Accuracy 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.","severity":"gotcha","affected_versions":"Older versions (pre-0.8.0) were more susceptible. Users should be aware for all versions in edge cases."},{"fix":"For performance-critical applications involving array processing, ensure `numpy` is installed in your environment (`pip install numpy`).","message":"While 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.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}