# Converting Between UTM and Latitude/Longitude Coordinates

QUESTION: Do you have any software to convert back and forth between UTM and latitude/longitude coordinates? I want to specify a latitude and longitude and have it converted to an east and north UTM coordinate. Then, I want to be able to convert an east/north UTM coordinate into a latitude/longitude coordinate. I'm going crazy looking all over the Internet for software to do this.

NOTE: A different (more thorough and harder to understand) treatment of this topic can be found in this article.

ANSWER: You don't need software to do this. IDL comes with map projection software. This is simply a forward (lat/lon to UTM) and/or inverse (UTM to lat/lon) transformation of a map projection. You can set the map projection up with *Map_Proj_Init *and then use *Map_Proj_Forward *and *Map_Proj_Inverse *to do the transformations, or you can simply use the cgMap object from the Coyote Library, which will do the transformations for you with its *Forward *and *Inverse *methods.

The only "trick" (if there is one), is to set up the UTM map projection space correctly. Normally, the only hard thing about this is knowing what UTM zone you want. But, if you have a latitude and longitude value, you can use the Coyote Library routine cgUTMZone to return the correct zone number.

Suppose, for example, you wanted to convert from UTM coordinates to latitude/longitude coordinates in the area of Fort Collins, Colorado. Fort Collins is at 40.6 degrees North and 105.1 degrees West. You can find the UTM zone in this area like this.

IDL> Print, cgUTMZone(-105.1, 40.6) 13

So, to create a map projection space using this UTM zone, you would create the map coordinate object like this. Use the correct ellipsoid for the data you are working with. This is normally WGS84 for satellite data. Your latitude and longitude values will be determined by the datum or ellipsoid you use. In other words, the same UTM coordinate will give slightly different latitude and longitude values, depending upon the ellipsoid you are using to calculate these values. Be sure you use the right one.

mapCoord = Obj_New('cgMap', 'UTM', Zone=cgUTMZone(-105.1, 40.6), Ellipsoid='WGS84')

Or, if you have IDL 8 or higher, like this.

mapCoord = cgMap('UTM', Zone=cgUTMZone(-105.1, 40.6), Ellipsoid='WGS84')

If you are working with an image, and the image is in a GeoTiff file, then creating the map coordinate object is even easier. You simply do this, where *myGeoTiffFile *is a string variable containing the name of your GeoTiff file.

mapCoord = cgGeoMap(myGeoTiffFile)

Then, if you want to convert latitude/longitude to UTM coordinates, you simply perform a forward map transformation, using the Forward method of the map coordinate object. Suppose, you want the UTM coordinates for Fort Collins.

IDL> Print, mapCoord -> Forward(-105.1, 40.6) 491539.34 4494359.4

Or, in IDL 8 or higher.

IDL> Print, mapCoord.Forward(-105.1, 40.6) 491539.34 4494359.4

To go from UTM coordinates to latitude/longitude, you simple use the inverse transformation in a similar way.

IDL> Print, mapCoord -> Inverse(491539.11, 4494148.3) -105.10000 40.599999

Or, in IDL 8 or higher.

IDL> Print, mapCoord.Inverse(491539.11, 4494148.3) -105.10000 40.599999

Converting from one coordinate system to the other is as simple as that.

Since UTM coordinates are nothing more than projected meters. This way of transferring from one coordinate system to another works with any map projection supported by IDL.

*Version of IDL used to prepare this article: IDL 8.2.3.*