Monday, 16 July 2012

Convert Latitude and Longitude From Degrees Minutes Seconds format to Decimal

Latitudes and Longitudes are mostly represented in the DMS (Degrees Minutes Seconds) format but for many applications, you need the values in decimal format. The decimal values can be easily stored and retrieved from database compared to DMS format. For creating maps using applications like Google Maps, it would be quite simple if you have those values in decimal format. In this post, the steps involved in this conversion are described.

To make things easier to understand, lets proceed with an example. Suppose you want to convert 33° 25' 17" to decimal.
The steps involved will be :
  • First convert the minutes to seconds. For this multiply the minutes with 60. So in our example we will have 25 * 60 = 1500.
  • Then add the seconds to the value obtained from above step. Then we will have 17 + 1500 = 1517. This will be the total number of seconds.
  • Now divide the total number of seconds by 3600. So we will have 1517 / 3600 = 0.421388889.
  • Now add this value to the degrees to obtain the final decimal value. 0.421388889 + 33 = 33.421388889.
So the decimal representation for  33° 25' 17" will be 33.421388889.

This method is same for both latitude and longitude. But this is not complete. There is one more part involved.

When you write latitude in DMS format, you will be specifying the reference as N (North) or S (South) at the end. So you will be writing latitude as 33° 25' 17" N or 33° 25' 17" S. To differentiate both, the decimal value for latitudes with reference S (South) will be preceded  with a negative sign.
So,
33° 25' 17" N will be 33.421388889 and
33° 25' 17" S will be -33.421388889.

Similarly in the case of longitude, you will have a reference like E (East) and W (West). To differentiate both, the decimal value for longitudes with reference W (West) will be preceded  with a negative sign.

No comments:

Post a Comment