javageolocationgeospatialgeotools

how to convert between degrees, minutes, seconds to Decimal coordinates


Looking for a java utility. It is even better if you can tell me how to do it using geotools library.


Solution

  • By "Decimal coordinates" do you mean latitude and longitude (also known as the decimal degree)? If so, what you're trying to do is pretty easy:

    Given a DMS (Degrees, Minutes, Seconds) coordinate such as W87°43′41″, it's trivial to convert it to a number of decimal degrees using the following method: Calculate the total number of seconds, 43′41″ = (43*60 + 41) = 2621 seconds. The fractional part is total number of seconds divided by 3600. 2621 / 3600 = ~0.728056 Add fractional degrees to whole degrees to produce the final result: 87 + 0.728056 = 87.728056

    Since it is a West longitude coordinate, negate the result. The final result is -87.728056.

    From Wikipedia. Here's a Javascript widget that does the same thing.