gdalraster

R-CMD-check codecov R-hub CRAN status r-universe status OpenSSF Best Practices OpenSSF Scorecard

Overview

gdalraster is an R interface to the Raster and Vector APIs of the Geospatial Data Abstraction Library (GDAL).

API-level bindings are implemented in the exposed C++ classes GDALRaster and GDALVector, along with several stand-alone functions. Bindings to the GDAL Virtual Systems Interface (VSI) are also included to support file system operations and binary I/O on URLs, cloud storage services, Zip/GZip/7z/RAR, and in-memory files, as well as regular file systems. Calling signatures resemble the native C, C++ and Python APIs provided by the GDAL project. Supports:

Additional functionality includes:

gdalraster may be useful in applications that need scalable, low-level I/O, or prefer a direct GDAL API. Comprehensive documentation is provided in the package and online.

Installation

Install the released version from CRAN with:

install.packages("gdalraster")

CRAN provides pre-compiled binary packages for Windows and macOS. These do not require any separate installation of external libraries for GDAL.

From source code

Linux

GDAL >= 3.1.0 built with GEOS is required, but a more recent version is recommended.

On Ubuntu, recent versions of geospatial libraries can be installed from the ubuntugis-unstable PPA with the following commands. Note that libxml2 is required for the R package xml2 which is a dependency, so we go ahead and install it here as well:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt install libgdal-dev libgeos-dev libxml2-dev

The versions in ubuntugis-unstable generally work well and are more up-to-date, but less recent versions in the ubuntugis-stable PPA could be used instead.

Package sf provides helpful instructions for installing the geospatial libraries on other Linux distributions.

With the dependent libraries available on the system, install from CRAN:

install.packages("gdalraster")

Or install the development version from GitHub using package remotes:

remotes::install_github("USDAForestService/gdalraster")

Windows

RTools is needed to install from source on Windows. RTools since version 4.2 includes GDAL and all other dependent libraries that are needed to compile gdalraster. Note that CRAN releases periodic revisions to RTools that often include updates to the libraries as new versions become available. Release 6536 of RTools 4.5 contains GDAL 3.10.2, GEOS 3.13.1 and PROJ 9.5.1.

With RTools installed:

# Install the development version from GitHub
remotes::install_github("USDAForestService/gdalraster")

macOS

GDAL can be installed with Homebrew:

brew install gdal

then

# Install the development version from GitHub
remotes::install_github("USDAForestService/gdalraster")

Caution is warranted on macOS with regard to mixing a source installation with installation of binaries from CRAN. Consider installing the development version from R-universe instead.

From R-universe

R-universe provides pre-compiled binary packages for Windows and macOS that track the development version of gdalraster. New packages are built usually within ~1 hour of the most recent commit in branch main.

# Install the development version from r-universe
install.packages("gdalraster", repos = c("https://usdaforestservice.r-universe.dev", "https://cran.r-project.org"))

Documentation