# Ruminations on Rust Geodesy ## Rumination 003: `kp` - the RG Coordinate Processing program Thomas Knudsen 2021-08-28. Last [revision](#document-history) 2023-11-24 ### Abstract ```console $ echo 55 12 | kp "geo:in | utm zone=32" > 691875.6321 6098907.8250 ``` --- ### Prologue `kp` is the Rust Geodesy **coordinate processing** program. The obvious abbreviation of coordinate processing is `cp`, but since `cp` is the Unix file copying program we substitute k for c - hence `kp`, which may be taken as a reference to the Danish word for coordinate processing **koordinatprocessering**. Incidentally, `kp` was also the user-id and email address of the late **Knud Poder** (1925-2019), during his work years at the Danish geodetic institute, GI (and its successor, KMS), from the 1950s until his retirement in 1995. For many years, Poder was in charge of the GI department for computational geodesy where, for some years around 1980, his deputy was Carl Christian Tscherning (1942-2014), for whom the [PROJ](https::/proj.org) transformation program [cct](https://proj.org/apps/cct.html) was named. Among friends, colleagues and collaborators worldwide, Knud Poder was regarded a Nestor of computational geodesy. ### Usage The basic operation of `kp` is very simple. Any complexity in `kp` usage is related to the description of the operation to carry out, which is the subject of [Rumination 002](/ruminations/002-rumination.md). The `kp` command line syntax is: ```console $ kp "operation" file1 file2 ... > ... ``` or, with input from `stdin`: ```console $ echo coordinate | kp "operation" > ... ``` or, with output to the file `result`: ```console $ kp -o result "operation" file1 file2 ... > ... ``` ### Examples Convert the coordinate tuple (55 N, 12 E) from geographical coordinates on the GRS80 ellipsoid to Universal Transverse Mercator, zone 32 coordinates on the same (implied) ellipsoid: ```sh $ echo 55 12 0 0 | kp "geo:in | utm zone=32" > 691875.6321 6098907.8250 ``` While RG coordinates are always 4D, `kp` will provide zero-values for any left-out postfix dimensions, and try to guess a proper number of output dimensions (unless the `-D n` option is given): ```console $ echo 55 12 | kp "geo:in | utm zone=32" > 691875.6321 6098907.8250 $ echo 55 12 | kp -D3 "geo:in | utm zone=32" > 691875.6321 6098907.8250 0.0000 $ echo 55 | kp "curvature mean" > 6385431.75306 $ echo 55 | kp -D4 "curvature mean" > 6385431.75306 0.00000 0.00000 NaN ``` The `roundtrip` option measures the roundtrip accuracy of a transformation (i.e. how close to the origin you end up after a forward+inverse dance). Knud Poder championed this practise with his ingeniously constructed *Poder dual autochecking* method, which was essential at a time where computers were less robust than today (more about that [below](#a-few-more-words-about-knud-poder)). ```console $ echo 55 12 | kp --roundtrip "geo:in | utm zone=32" > -0.0000000000 -0.0000000000 ``` The `inv` option runs the specified pipeline inversely: ```console $ echo 691875.6321 6098907.8250 | kp --inv "geo:in | utm zone=32" > 54.9999999996 11.9999999994 0.00000 0.00000 ``` ### Options The `help` option gives the list of options: ```txt $ kp --help KP: The Rust Geodesy 'Coordinate Processing' program Usage: kp.exe [OPTIONS] [ARGS]... Arguments: The operation to carry out e.g. 'kp "utm zone=32"' [ARGS]... The files to operate on Options: --inv Inverse operation -z, --height Specify a fixed height for all coordinates -t, --time