# How do you convert to DMS from 9-digit LAT/LON code? [duplicate]

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

EXAMPLE:

Longitude is 81°5.8'
Code is 081054800

Page 9 of document found here explains:
http://www.fhwa.dot.gov/bridge/mtguide.pdf

The data can be found here:
http://www.fhwa.dot.gov/bridge/nbi/ascii.cfm

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?

Thanks!

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

-m

-
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

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

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,

-
+1 for a shell script solution, lol! –  whuber May 29 '13 at 13:58