| Title: | Windows GDAL Runtime and gdalraster Bootstrap Tools |
|---|---|
| Description: | Installs and activates a self-contained GDAL runtime on Windows and provides helpers to install gdalraster from source against that GDAL instead of the default Rtools GDAL. |
| Authors: | Jimmy Briggs [aut, cre] (ORCID: <https://orcid.org/0000-0002-7489-8787>) |
| Maintainer: | Jimmy Briggs <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.1 |
| Built: | 2026-07-04 02:00:38 UTC |
| Source: | https://github.com/jimbrig/gdalraster.windows |
Prepends runtime paths, sets GDAL/PROJ env vars, and preloads GDAL DLL.
activate_gdal_runtime( gdal_home = default_gdal_home(), preload = TRUE, quiet = FALSE )activate_gdal_runtime( gdal_home = default_gdal_home(), preload = TRUE, quiet = FALSE )
gdal_home |
GDAL home directory. |
preload |
Whether to preload |
quiet |
Suppress informational CLI output. |
When the runtime bundle contains a python/ directory (pure-python
osgeo_utils package from GDAL's gdal-utils distribution), it is
prepended to PYTHONPATH so GDAL algorithms that embed Python at runtime
(e.g. gdal driver gpkg validate) can import it. This is session-scoped
and does not modify machine or user environment variables.
When preload = TRUE and the GDAL DLL cannot be loaded (most commonly
because a dependency DLL is missing), activation fails with an error
rather than deferring the failure to library(gdalraster), where the
Windows loader reports only a generic "module could not be found".
Invisibly returns a list with configured paths.
Writes a managed hook block into an .Rprofile file. The block loads the
bundled GDAL DLL before package attach and prepends the custom gdalraster
library path.
add_gdal_rprofile_hook( rprofile = "~/.Rprofile", gdal_home = default_gdal_home(), lib = default_gdalraster_lib(), dry_run = FALSE )add_gdal_rprofile_hook( rprofile = "~/.Rprofile", gdal_home = default_gdal_home(), lib = default_gdalraster_lib(), dry_run = FALSE )
rprofile |
Target |
gdal_home |
GDAL home directory. |
lib |
Library path containing the custom gdalraster install. |
dry_run |
If |
Invisibly returns the updated .Rprofile text.
Sets GDAL home for this session using either an R option or environment variable. This does not write to user profile files.
configure_gdal_home(path, mode = c("option", "env"))configure_gdal_home(path, mode = c("option", "env"))
path |
GDAL home directory path. |
mode |
Either |
Invisibly returns the normalized GDAL home path.
Returns the currently configured GDAL runtime home used by this package.
gdal_home()gdal_home()
Resolution order:
options(gdalraster.windows.gdal_home = "...")
GDALRASTER_WINDOWS_GDAL_HOME environment variable
package-managed user data directory (tools::R_user_dir())
A single string path.
Returns R code that loads the bundled GDAL DLL before attaching
gdalraster, and prepends the custom lib path so library(gdalraster)
resolves to the source build installed by install_gdalraster().
gdal_rprofile_snippet( gdal_home = default_gdal_home(), lib = default_gdalraster_lib() )gdal_rprofile_snippet( gdal_home = default_gdal_home(), lib = default_gdalraster_lib() )
gdal_home |
GDAL home directory. |
lib |
Library path containing the custom gdalraster install. |
A single string containing R code.
Installs the GDAL runtime into gdal_home from one of:
install_gdal_runtime( repo = .bundle_repo, tag = "latest", asset_pattern = .bundle_asset_pattern, gdal_home = default_gdal_home(), overwrite = FALSE, local_zip = NULL, fallback_zip = NULL )install_gdal_runtime( repo = .bundle_repo, tag = "latest", asset_pattern = .bundle_asset_pattern, gdal_home = default_gdal_home(), overwrite = FALSE, local_zip = NULL, fallback_zip = NULL )
repo |
GitHub repo slug publishing the runtime bundle releases.
Defaults to |
tag |
Release tag or |
asset_pattern |
Regex used to select the release asset. Defaults to
the runtime bundle zip naming convention
( |
gdal_home |
Destination GDAL home directory. |
overwrite |
Whether to replace existing |
local_zip |
Optional local GDAL runtime zip to install directly. |
fallback_zip |
Optional fallback zip path used when release download
fails. When |
local_zip (highest precedence),
GitHub release asset lookup/download,
fallback_zip when release lookup/download fails.
The selected zip must contain a GDAL root with bin/libgdal-*.dll.
Invisibly returns installed GDAL home path.
On machines without network access, download the release asset manually from https://github.com/jimbrig/gdalraster.windows/releases, transfer it to the target machine, and install directly:
gdalraster.windows::install_gdal_runtime( local_zip = "C:/Downloads/gdal-ucrt64-v3.13.1-windows-x64.zip" )
Note that no fallback zip is shipped with the package (a full runtime
bundle is too large to vendor), so the fallback path only applies when you
provide a fallback_zip yourself.
With overwrite = TRUE, the existing gdal_home is deleted before the new
runtime is copied in. Runtime DLLs that were preloaded into the current
session (the package auto-bootstrap does this at load time when a runtime
is present) are unloaded first so the process does not block its own
reinstall. This is not possible when gdalraster is loaded — its DLL pins
the GDAL runtime in the process — so reinstalling then requires a fresh R
session. Deletion is verified before copying: if another process holds
locks on the runtime (another R session, a File Explorer preview pane), the
install aborts cleanly instead of leaving a partially-replaced runtime.
Downloads or uses a local gdalraster source tarball and installs it from
source into a dedicated library path (default) so existing user libraries
are not overwritten. To install into your regular user library instead
(so plain library(gdalraster) resolves the source build without this
package's load helpers), pass it explicitly, e.g.
install_gdalraster(lib = .libPaths()[1]).
install_gdalraster( gdal_home = default_gdal_home(), lib = default_gdalraster_lib(), source_tarball = NULL, repo = .gdalraster_repo, ref = "HEAD", upgrade = FALSE, repos = getOption("repos") )install_gdalraster( gdal_home = default_gdal_home(), lib = default_gdalraster_lib(), source_tarball = NULL, repo = .gdalraster_repo, ref = "HEAD", upgrade = FALSE, repos = getOption("repos") )
gdal_home |
GDAL home directory used for compile/link flags. |
lib |
Destination library path for installing gdalraster. Defaults to
an isolated package-managed library; pass |
source_tarball |
Optional local path to |
repo |
Source GitHub repo slug for gdalraster. Defaults to
|
ref |
Git ref (branch, tag, commit) used when downloading from GitHub. |
upgrade |
When |
repos |
CRAN-like repositories used to satisfy R package dependencies
when |
Invisibly returns installed library path.
This is a source compilation, so
Rtools matching your R
version must be installed (the one thing the prebuilt runtime bundle cannot
eliminate). The function checks for a toolchain up front and aborts with
guidance when none is found. The GDAL runtime bundle itself must already be
installed via install_gdal_runtime().
After installing a new runtime bundle version
(install_gdal_runtime(overwrite = TRUE)), rerun this function — the
previous gdalraster build is bound to the previous bundle's GDAL and must
be recompiled against the new one.
Convenience wrapper over activate_gdal_runtime() that ensures the GDAL
runtime is activated and the main GDAL DLL is preloaded in the current
session.
load_gdal_dll(gdal_home = default_gdal_home(), quiet = FALSE)load_gdal_dll(gdal_home = default_gdal_home(), quiet = FALSE)
gdal_home |
GDAL home directory. |
quiet |
Suppress informational CLI output. |
Invisibly returns activation metadata.
Activates bundled GDAL runtime, prepends lib to .libPaths(), and attaches
gdalraster for use in the current R session.
load_gdalraster( lib = default_gdalraster_lib(), gdal_home = default_gdal_home(), quiet = FALSE )load_gdalraster( lib = default_gdalraster_lib(), gdal_home = default_gdal_home(), quiet = FALSE )
lib |
Library path containing the gdalraster source install. |
gdal_home |
GDAL home directory. |
quiet |
Suppress informational CLI output. |
Invisibly returns TRUE if gdalraster was attached.
Attempts to load gdalraster and checks the global algorithm registry.
verify_gdalraster_runtime( lib.loc = NULL, activate_runtime = TRUE, gdal_home = default_gdal_home(), quiet = FALSE )verify_gdalraster_runtime( lib.loc = NULL, activate_runtime = TRUE, gdal_home = default_gdal_home(), quiet = FALSE )
lib.loc |
Optional library location used for loading |
activate_runtime |
Whether to run |
gdal_home |
GDAL home used when |
quiet |
If |
TRUE when algorithm API is available, otherwise FALSE
(including when runtime activation itself fails).