0

Possible Duplicate:
how to convert between degrees, minutes, seconds to Decimal coordinates

I have 39°07.356"N and 121°02.482"W and i need to convert it to Decimal Degrees. any source?

Community
  • 1
  • 1
  • 1
    http://stackoverflow.com/questions/8263959/how-to-convert-between-degrees-minutes-seconds-to-decimal-coordinates – Alex Gelman Oct 13 '12 at 08:23

1 Answers1

1

You can use the following function to perform the task

public decimal DmsToDD(double d, double m = 0, double s = 0)
{
    return Convert.ToDecimal((d + (m/60) + (s/3600))*(d < 0 ? -1 : 1));
}

Of course, you'll need to check to make sure the minute and second components are non-negative before you do the conversion.

Alex Essilfie
  • 12,339
  • 9
  • 70
  • 108