When you start working with multiple datasets you'll inevitably end up with data in different coordinate systems and projections. You can convert back and forth between Universal Transverse Mercator (UTM) and latitude/longitude using a pure Python module called utm
. You can install it using easy_install
or pip
from PyPI available at the following link:
https://pypi.python.org/pypi/utm
The utm
module is straightforward to use. To convert from UTM to latitude and longitude, use the following commands:
>>> import utm >>> y = 479747.0453210057 >>> x = 5377685.825323031 >>> zone = 32 >>> band = 'U' >>> print(utm.to_latlon(y, x, zone, band)) >>> (48.55199390882121, 8.725555729071763)
The UTM zones are numbered horizontally. However, vertically, the bands of latitude are ordered by English alphabets with a few exceptions. The letters A, B, Y, and Z cover the poles. The letters I and O are omitted because they look too much like 1 and 0. Letters N through X are in the northern hemisphere, while C through M are in the southern hemisphere. The following figure from the website, Atlas Florae Europaeae, illustrates the UTM zones over Europe:
Converting from latitude and longitude is even easier. We just pass the latitude and longitude to the from_latlon()
method, which returns a tuple with the same parameters accepted by the to_latlon()
method:
>>> import utm >>> utm.from_latlon(48.55199390882121, 8.725555729071763) (479747.04524576373, 5377691.373080335, 32, 'U')
The algorithms used in this Python implementation are described in detail and are available at the following link: