Package 'rgeodesy'

Title: R Interface to Rust Geodesy
Description: Provides R bindings to the Rust Geodesy library by Thomas Knudsen, a platform for experiments with geodetic transformations and data flow. Exposes the pipeline operator model — compose transformations from named primitives such as 'utm', 'helmert', 'molodensky', and 'geo:in' adaptors — and apply them to vectors of coordinates. Useful for learning the Rust Geodesy architecture and for geodetic operations not available in 'PROJ'-based tools.
Authors: Michael Sumner [aut, cre] (ORCID: <https://orcid.org/0000-0002-2471-7511>)
Maintainer: Michael Sumner <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-10-16 12:42:48 UTC
Source: https://github.com/hypertidy/rgeodesy

Help Index


Apply a Rust Geodesy pipeline to coordinate vectors

Description

Compiles the pipeline once and applies it, vectorised, to all coordinate pairs. Coordinates follow Rust Geodesy conventions: geographic data must be bracketed with an adaptor operator (⁠gis:in⁠/gis:out for ⁠(lon, lat)⁠ in degrees, or ⁠geo:in⁠/geo:out for ⁠(lat, lon)⁠), because RG works internally in radians.

Usage

geod_apply(op_str, x, y, inv = FALSE)

Arguments

op_str

Character scalar. A Rust Geodesy pipeline string, e.g. "gis:in | utm zone=32".

x

Numeric vector. First coordinate (longitude/easting under the GIS convention).

y

Numeric vector. Second coordinate (latitude/northing). Must be the same length as x.

inv

Logical scalar. Run the inverse operation. Default FALSE.

Value

A named list with numeric elements x and y, each the same length as the input.

See Also

geod_xy() for matrix output, geod_validate(), geod_ops()

Other rgeodesy functions: geod_ops(), geod_validate(), geod_xy()

Examples

# 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))

# Round trip: forward then inverse recovers the input
fwd <- geod_apply("gis:in | utm zone=55 south", x = 147.3, y = -42.9)
geod_apply("gis:in | utm zone=55 south", x = fwd$x, y = fwd$y, inv = TRUE)

# Multi-step pipeline: geographic in, northing-easting-up out
geod_apply("gis:in | utm zone=32 | neu:out", x = c(12, 18), y = c(55, 59))

List available Rust Geodesy operators

Description

Returns the names of the built-in operators and coordinate adaptors registered in a Minimal Rust Geodesy context. The list reflects the crate version pinned by the package (Rust Geodesy 0.15).

Usage

geod_ops()

Value

A sorted character vector of operator names.

See Also

Other rgeodesy functions: geod_apply(), geod_validate(), geod_xy()

Examples

ops <- geod_ops()
length(ops)
c("utm", "helmert", "laea") %in% ops

Validate a Rust Geodesy pipeline string

Description

Attempts to compile the pipeline and returns TRUE if it succeeds, or a character string describing the error if it fails. Useful for checking a pipeline interactively before passing it to geod_apply().

Usage

geod_validate(op_str)

Arguments

op_str

Character scalar. A pipeline string to validate.

Value

TRUE if valid, otherwise a character string with the error message.

See Also

Other rgeodesy functions: geod_apply(), geod_ops(), geod_xy()

Examples

geod_validate("gis:in | utm zone=55 south")  # TRUE
geod_validate("utm zone=banana")             # error string

Apply a pipeline and return a two-column matrix

Description

Convenience wrapper around geod_apply() that returns a numeric matrix with columns x and y rather than a list.

Usage

geod_xy(op_str, x, y, inv = FALSE)

Arguments

op_str

Character scalar. A Rust Geodesy pipeline string, e.g. "gis:in | utm zone=32".

x

Numeric vector. First coordinate (longitude/easting under the GIS convention).

y

Numeric vector. Second coordinate (latitude/northing). Must be the same length as x.

inv

Logical scalar. Run the inverse operation. Default FALSE.

Value

A numeric matrix with columns x and y, one row per input point.

See Also

Other rgeodesy functions: geod_apply(), geod_ops(), geod_validate()

Examples

geod_xy("gis:in | utm zone=55 south", x = c(147.3, 147.5), y = c(-42.9, -42.8))