question

siugoalie78 avatar image
siugoalie78 asked

Convert Degrees Minutes Seconds to Decimal Degrees or Geography

Hopefully somebody already has a nice elegant method for this, and is willing to share. My DB is storing Latitude and Longitude in Degrees/Minutes/Seconds format, in a single string (one for Lat, one for Lon) . Example: Lat = 123456N; Lon = 1234560E. I need to convert these to Decimal, so I can then convert to SQL Geography datatype. Or better yet, directly from DMS to Geography. One caveat: Lat is always 6 numbers, followed by a 'N' or 'S', but Lon could be either 6 or 7 numbers (7 if 100 degrees or more) and if only 6 are listed, then it can be assumed there should be a leading zero. I figured rather than reinvent the wheel ,I would reach out to see if it had already been done.
geographysql-2008-r2
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
GPO avatar image
GPO answered
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.