Search code examples
bashgridlatitude-longitudeutmwgs84

Bash code to convert UTM x/y to lat/long Decimal Degrees


I was wondering if there is a bash code (or maybe other language, e.g. Python, Perl) to convert UTM x/y coordinates to lat/long coordinates? A code that can convert multiple coordinates at a time. I'm working in UTM zone 29N, using WGS84 datum.

Example of UTM x/y coordinates:

616928  6877084
621751  6877314
614317  6871645
588506  6883397
570571  6886266

Desired output in Decimal Degrees:

62.008000   -6.766680087
62.008542   -6.674491852
61.960009   -6.819994839
62.072357   -7.306064871
62.101883   -7.648054115

Solution

  • To convert a single coordinate

    echo 616928  6877084  | gdaltransform -s_srs epsg:25829 -t_srs epsg:4326
    

    To convert a set of coordinates like your example:

    616928  6877084
    621751  6877314
    614317  6871645
    588506  6883397
    570571  6886266
    

    Save them to coords.txt and run:

    cat coords.txt | gdaltransform -s_srs epsg:25829 -t_srs epsg:4326