R bindings to Rust Geodesy (RG) by Thomas Knudsen — a platform for experiments with geodetic transformations and data flow. You build a transformation by writing a pipeline string of named operators and apply it to vectors of coordinates.
RG is a geodesy library rather than a cartography library: its datum and reference-frame machinery is extensive, and it supports a focused, high-quality set of map projections. It is well suited to learning the RG architecture and to geodetic operations that are awkward in PROJ-based tooling.
rgeodesy compiles a small Rust crate at install time, so you need a Rust
toolchain (install via rustup, rustc >= 1.87):
# install.packages("remotes")
# remotes::install_github("hypertidy/rgeodesy")
install.packages("rgeodesy", repos = c('https://hypertidy.r-universe.dev', 'https://cloud.r-project.org'))
library(rgeodesy)
# Geographic (lon, lat) in degrees -> UTM zone 55 south (easting, northing).
geod_apply("gis:in | utm zone=55 south", x = c(147.3, 147.5), y = c(-42.9, -42.8))
#> $x
#> [1] 524492.1 540886.1
#> $y
#> [1] 5250246 5261273
# The same thing as a two-column matrix.
geod_xy("gis:in | utm zone=55 south", x = c(147.3, 147.5), y = c(-42.9, -42.8))
#> x y
#> [1,] 524492.1 5250246
#> [2,] 540886.1 5261273
# Inverse: projected -> geographic (set inv = TRUE on the forward pipeline).
m <- geod_xy("gis:in | utm zone=55 south", x = 147.3, y = -42.9)
geod_apply("gis:in | utm zone=55 south", x = m[, "x"], y = m[, "y"], inv = TRUE)
#> $x
#> [1] 147.3
#> $y
#> [1] -42.9
Rust Geodesy does not use EPSG codes or a from -> to pair of CRSs.
Instead you describe the transformation directly as a pipeline of operator
primitives, chained with |, each taking key=value arguments:
gis:in | utm zone=32 | gis:out
Because RG works internally in radians with a geodetic axis order, geographic data is bracketed with an I/O adaptor:
| Adaptor | Units | Order | Use for |
|---|---|---|---|
gis:in / gis:out
|
degrees | (lon, lat) |
natural (x, y) — recommended |
geo:in / geo:out
|
degrees | (lat, lon) |
geodetic latitude-first |
enu:in / neu:in
|
radians | east/north-first | already-radian input |
Validate a pipeline before using it:
geod_validate("gis:in | utm zone=55 south") # TRUE
geod_validate("utm zone=banana") # "Failed to build op ...: Malformed value ..."
geod_ops() returns the full list of registered operators. The main families:
| Family | Operators |
|---|---|
| Projections |
utm, tmerc, btmerc/butm (Bowring series), merc, webmerc, lcc, laea, omerc, somerc
|
| Datum / reference-frame |
cart, helmert, molodensky, gridshift, deformation
|
| Geodetic computations |
geodesic, curvature, gravity, latitude, deflection, permtide
|
| Adaptors & units |
adapt, axisswap, unitconvert, dm, dms, geo:*/gis:*/neu:*/enu:*, noop
|
See the Rust Geodesy operator documentation for the arguments each operator accepts.
x, y) per point. Operators that
are inherently three-dimensional (cart, helmert, deformation) need a
height component to round-trip correctly, so full 3-D datum transforms are not
yet usable through this 2-D interface. Projections and 2-D operators work as
expected.Please note that the rgeodesy project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.