Finding UTM zones based on given latitude and longitude

 UTM (Universal Transverse Mercator) is a projected coordinate system. Its a meter based coordinate system which gives where earth is divided into 60 longitudinal zones and the coordinate values in each zone is in meters within that zone. The origin of each zone is located at the intersection of intersection of the equator and a longitudinal boundaries of each zone.

Very often the WGS84 coordinates which are expressed in longitude and latitude and are referred as EPSG:4326 coordinates are converted to UTM to do several geospatial operations where a meter based distance is used or expected as an output of that geospatial operations. Since UTM is more accurate than other meter based counter parts its becomes a good choice to convert the WGS84, EPSG:4326 coordinates to meters using UTM.

 Given below is a method to get the EPSG code of UTM zones which I often use on a day to day basis for my geospatial work.

The method  findEPSG calls the method getZones which internally uses

(math.floor((longitude + 180) / 6)) +

to internally calculate an integer zone value based on longitude. The other conditions in getZone are for the countries Norway and Svalbard as they are treated as special cases.

The Universal Transverse Mercator (UTM) is not strictly divided in 6° width zones. There are exceptions for Svalbard and Norway. These exceptions orginated due to historical reasons since UTM was designed by military around World War II and they wanted Norway and Svalbard the 2 small countries to be not split into 2 UTM zones. It can be seen in the image below from Wikimedia Commons how these exceptions resulted into unequal UTM zones around these countries.



It can be noticed that,

  • Between 56°N and 64°N, zone 32 is widened to 9° (at the expense of zone 31) to accommodate southwest Norway.
  • Between 72°N and 84°N, zones 33 and 35 are widened to 12° to accommodate Svalbard. To compensate for these 12° wide zones, zones 31 and 37 are widened to 9° and zones 32, 34, and 36 are eliminated.

The "if conditions" in getZones are for the the same cases. Once an appropriate zone value is returned by getZones the findEPSG method adds a starting value of 32600 to the calculated zone to derive EPSG code. Here we also check for the latitude. If the latitude is in southern hemisphere i.e <0 we add an additonal 100 value to the calculated zone else we keep it as is. Finally appending it with "EPSG:" string gives you an EPSG zone which can be used for further geospatial operations. 

Thats it for this blog!  To summarize, a method of calculating EPSG codes from a given latitude and longitude is explained in detail.

Comments

Popular posts from this blog

Developing Garmin SmartWatch Apps with ConnectIQ Platform-Part 3

Developing Garmin SmartWatch Apps with ConnectIQ Platform-Part 1

Web Service Security and Native Mobile App User Authentication