GeoConvert
convert geographic coordinates
- Provided by: geographiclib-tools (Version: 1.21-1ubuntu1)
- Source: geographiclib
- Report a bug
convert geographic coordinates
GeoConvert [ -g | -d | -: | -u | -m | -c ] [ -p prec ] [ -z zone | -s | -t ] [ -n ] [ -w ] [ --comment-delimiter commentdelim ] [ --version | -h | --help ] [ --input-file infile | --input-string instring ] [ --line-separator linesep ] [ --output-file outfile ]
GeoConvert reads from standard input interpreting each line as a geographic coordinate and prints the coordinate in the format specified by the options on standard output. The input is interpreted in one of three different ways depending on how many space or comma delimited tokens there are on the line. The options -g, -d, -u, and -m govern the format of output. In all cases, the WGS84 model of the earth is used (a = 6378137 m, f = 1/298.257223563).
33.3 44.4
E44.4 N33.3
33d18'N 44d24'E
44d24 33d18N
33:18 44:24
38N 444140.54 3684706.36
444140.54 3684706.36 38N
S 2173854.98 2985980.58
2173854.98 2985980.58 S
38SMB4484
38SMB44140847064
prec gives precision of the output with prec = 0 giving 1 m precision, prec = 3 giving 1 mm precision, etc. prec is the number of digits after the decimal point for UTM/UPS. The number of digits per coordinate for MGRS is 5 + prec. For decimal degrees, the number of digits after the decimal point is 5 + prec. For DMS (degree, minute, seconds) output, the number of digits after the decimal point in the seconds components is 1 + prec; if this is negative then use minutes (prec = -2 or -3) or degrees (prec <= -4) as the least significant component. Print convergence, resp. scale, with 5 + prec, resp. 7 + prec, digits after the decimal point. The minimum value of prec is -5 and the maximum is 9 for UTM/UPS, 9 for decimal degrees, 10 for DMS, 6 for MGRS, and 8 for convergence and scale.
MGRS coordinates represent a square patch of the earth, thus "38SMB4488" is in zone "38N" with 444km <= easting < 445km and 3688km <= northing < 3689km. Consistent with this representation, coordinates are truncated (instead of rounded) to the requested precision. Similarly, on input an MGRS coordinate represents the center of the square ("38N 444500 3688500" in the example above). However, if the -n option is given then the south-west corner of the square is returned instead ("38N 444000 3688000" in the example above).
If the input is geographic, GeoConvert uses the standard rules of selecting UTM vs UPS and for assigning the UTM zone (with the Norway and Svalbard exceptions). If the input is UTM/UPS, or MGRS, then the choice between UTM and UPS and the UTM zone mirrors the input. The -z zone, -s, -t options allow these rules to be overridden with zone = 0 being used to indicate UPS. For example, the point
79.9S 6.1E
corresponds to possible MGRS coordinates
32CMS4324728161 (standard UTM zone = 32)
31CEM6066227959 (neighboring UTM zone = 31)
BBZ1945517770 (neighboring UPS zone)
then
echo 79.9S 6.1E | GeoConvert -p -3 -m => 32CMS4328 echo 31CEM6066227959 | GeoConvert -p -3 -m => 31CEM6027 echo 31CEM6066227959 | GeoConvert -p -3 -m -s => 32CMS4328 echo 31CEM6066227959 | GeoConvert -p -3 -m -z 0 => BBZ1917
NOTE: the letter in the zone specification for UTM is a hemisphere designator N or S and not an MGRS latitude band letter. Convert the MGRS latitude band letter to a hemisphere as follows: replace C thru M by S; replace N thru X by N.
Unfortunately the characters ' and " have special meanings in many shells and have to be entered with care.
echo 30d30\'30\" "30d30'30" | GeoConvert -d -p -1
=> 30d30'30"N 030d30'30"E
Alternatively use colon separators, e.g., 30:30:30, which need no quoting.
echo 30d30'30^" 30d30'30 | GeoConvert -d -p -1
=> 30d30'30"N 030d30'30"E
Alternatively use colon separators, e.g., 30:30:30, which need no quoting.
GeoConvert -d -p -1 < input.txt
echo 38SMB4488 | GeoConvert => 33.33424 44.40363 echo 38SMB4488 | GeoConvert -: -p 1 => 33:20:03.25N 044:2413.06E echo 38SMB4488 | GeoConvert -u => 38N 444500 3688500 echo E44d24 N33d20 | GeoConvert -m -p -3 => 38SMB4488
An illegal line of input will print an error message to standard output beginning with "ERROR:" and causes GeoConvert to return an exit code of 1. However, an error does not cause GeoConvert to terminate; following lines will be converted.
The algorithms for the transverse Mercator projection are described in C. F. F. Karney, Transverse Mercator with an accuracy of a few nanometers, J. Geod 85(8), 475-485 (Aug. 2011); DOI http://dx.doi.org/10.1007/s00190-011-0445-3 <http://dx.doi.org/10.1007/s00190-011-0445-3>; preprint <http://arxiv.org/abs/1002.1417>.
GeoConvert was written by Charles Karney.
GeoConvert was added to GeographicLib, <http://geographiclib.sf.net>, in 2009-01.