Batch convert DMS to DD

These are instructions for Mac.

From http://www.kyngchaos.com/wiki/software:frameworks install the PROJ framework.

In your home directory create or edit a file called .bash_login

Add the line:

export PATH=/Library/Frameworks/PROJ.framework/Programs:$PATH

Have your lat long in a file, for example dms_file like this:


121d13'52.432"W 37d28'57.767"N
2d20'55"E48d51'12"N
etc..

(one point per line)

Use this command to convert all into Decimals Degrees and save them in a file called, for example dd_file. This example assumes WGS as datum.

cs2cs -f "%.6f" +proj=latlong +datum=WGS84 +to +proj=latlong +datum=WGS84 < dms_file > dd_file

Notes:
- cs2cs expects input data to formatted as "x y", so if working with latitude-longitude  data  be sure to send the x value first, i.e., "longitude latitude". Output data will be exported using the same convention.

- be sure to use the quotation mark for the seconds, not two apostrophes.

- the third column in the output is used for elevation (z).

- if you have GRASS installed, you can alternatively use m.proj

No TweetBacks yet. (Be the first to Tweet this post)