Take the 2-minute tour ×

This question already has an answer here:

I'm trying to map the national bridge inventory, but the coordinates are stored in this 9-digit code for LAT and LON


Longitude is 81°5.8'
Code is 081054800

Page 9 of document found here explains:

The data can be found here:

I've seen there are tools like Mimee, but I can't figure out how to run it on Ubuntu (tried to install correct libraries, etc.)

Is there maybe another way to do this?


(hoping this question isn't "too subjective" as stackexchange is suggesting...)


share|improve this question
This question is not subjective at all, but it is answered directly in many threads and indirectly in dozens of others: search our site on "dd dms" for example. –  whuber May 29 '13 at 13:57
add comment

marked as duplicate by whuber May 29 '13 at 13:57


2 Answers

If you're working in Ubuntu, you could use this in a shell script:

  1. To get longitude like 81°5.8' (degree and minutes from code in d,m,s):

    tmp0=`echo 081054800 | cut -c2,3`
    tmp1=`echo 081054800 | cut -c5`
    tmp2=`echo 081054800 | cut -c6,7`
    tmp3=`echo "scale=2; $tmp2/60" | bc -l`
    echo $tmp0 $tmp1 $tmp3 | awk '{ print $1"°"$2$3"'\''" }'

which gives: 81°5.80'

  1. To get longitude like 81.096666667 (decimal degrees from code in d,m,s):

    tmp0=`echo 081054800 | cut -c2,3`
    tmp1=`echo 081054800 | cut -c5`
    tmp2=`echo 081054800 | cut -c6,7`
    echo "scale=10; $tmp0+(($tmp1+$tmp3)/60)" | bc -l

which gives: 81.09666666666666666666

you can play with the scale to get the precision you need. Also, I think you need to do a complete list at once, then use a for loop for instance.

Hope this helps,

share|improve this answer
+1 for a shell script solution, lol! –  whuber May 29 '13 at 13:58
add comment

I'm sure what software you want to use or how you are handling that file, but since the Code is following XXX XX XX.XX for Deg Min Sec, respectively, you can convert manually:

Decimal Degrees = Degrees + ((Minutes / 60) + (Seconds / 3600))

Decimal Degrees = 81 + ((05 / 60) + (48.00 / 3600)) = 81.096667

share|improve this answer
add comment
