GDAL is available in R through high-level packages such as sf and terra, and through wrapper packages like gdalUtilities. These approaches work well for many use cases, but they share a fundamental limitation:
They bind against a specific GDAL build, not necessarily the GDAL binaries actually used on the system.
In practice, this leads to several recurring problems:
The goal of the link2GI GDAL context is
not to replace existing packages, but to expose
and control the system GDAL CLI deterministically.
The GDAL context introduced here follows a small set of strict principles:
Use the linked GDAL binaries explicitly
No implicit reliance on PATH, no guessing, no fallback to
other builds.
Be system-honest
The context reflects what the system can actually do, not what
a package was compiled against.
Remain thin and non-intrusive
No re-implementation of GDAL semantics, no competing wrapper
API.
Enable reproducibility
Every run can be fingerprinted and logged, including environment and
versions.
Support interactive and batch workflows
equally
From exploratory work to large batch runs or CI pipelines.
At the heart of the approach is a GDAL CLI context:
binDir containing GDAL executablesPATH, GDAL_DATA,
PROJ_LIB, …)This context is immutable for a run and can be reused safely.
linkGDAL()The recommended entry point is linkGDAL():
This locates a valid GDAL installation on the system. From this result, a deterministic CLI context is created:
At this point:
To document what this GDAL can do, a fingerprint can be collected:
This records, among other things:
Optionally, the fingerprint can be written to an NDJSON log for auditability.
A GDAL utility can now be executed explicitly:
Key properties:
PATHThis makes the call reproducible across machines as long as the same binaries are used.
One recurring pain point when using the GDAL CLI is remembering valid flags and argument structure.
The context provides a help-based skeleton:
This skeleton is derived directly from gdalwarp --help
and contains:
Usage: lineImportantly:
The skeleton does not guess semantics or defaults. It reflects exactly what this GDAL build exposes.
Skeletons can be combined with structured options:
args <- gdal_build_args(
sk,
opts = list(
t_srs = "EPSG:25832",
r = "bilinear"
),
positional = c("in.tif", "out.tif")
)This avoids error-prone copy-paste and keeps CLI usage explicit.
Every GDAL call can optionally be logged as one JSON object per line:
This format is:
It enables answering questions like:
Which GDAL, with which environment, produced this output?
This approach is complementary, not competitive:
sf / terra Excellent for in-memory workflows and analysis; rely on linked libraries.
gdalUtilities Provides R wrappers for many CLI tools, but still depends on system setup.
link2GI GDAL context Focuses on deterministic execution, capability introspection and traceability.
You can freely mix these approaches in one project.
Typical use cases include:
If you already rely heavily on the GDAL CLI, this approach removes ambiguity without adding conceptual overhead.
The GDAL CLI context in link2GI provides:
It is intentionally small, honest, and system-centric.
linkGDAL()