MyNixOS website logo
Description

Bindings to the 'Geospatial Data Abstraction Library' Raster API.

Interface to the Raster API of the 'Geospatial Data Abstraction Library' ('GDAL', <https://gdal.org>). Bindings are implemented in an exposed C++ class encapsulating a 'GDALDataset' and its raster band objects, along with several stand-alone functions. These support manual creation of uninitialized datasets, creation from existing raster as template, read/set dataset parameters, low level I/O, color tables, raster attribute tables, virtual raster (VRT), and 'gdalwarp' wrapper for reprojection and mosaicing. Includes 'GDAL' algorithms ('dem_proc()', 'polygonize()', 'rasterize()', etc.), and functions for coordinate transformation and spatial reference systems. Calling signatures resemble the native C, C++ and Python APIs provided by the 'GDAL' project. Includes raster 'calc()' to evaluate a given R expression on a layer or stack of layers, with pixel x/y available as variables in the expression; and raster 'combine()' to identify and count unique pixel combinations across multiple input layers, with optional output of the pixel-level combination IDs. Provides raster display using base 'graphics'. Bindings to a subset of the 'OGR' API are also included for managing vector data sources. Bindings to a subset of the Virtual Systems Interface ('VSI') are also included to support operations on 'GDAL' virtual file systems. These are general utility functions that abstract file system operations on URLs, cloud storage services, 'Zip'/'GZip'/'7z'/'RAR' archives, and in-memory files. 'gdalraster' may be useful in applications that need scalable, low-level I/O, or prefer a direct 'GDAL' API.

gdalraster

R-CMD-check codecov R-hub CRANstatus r-universestatus

Overview

gdalraster is an R interface to the Raster API of the Geospatial Data Abstraction Library (GDAL). Bindings to a subset of the GDAL Vector API are included to provide utilities for managing vector data sources. Bindings to the GDAL Virtual Systems Interface (VSI) 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.

Bindings to GDAL are implemented in the exposed C++ class GDALRaster along with several stand-alone functions, supporting:

  • manual creation of uninitialized raster datasets
  • creation from existing raster as template
  • read/set raster dataset parameters and metadata
  • low-level I/O
  • build/read/set color tables and raster attribute tables
  • virtual raster (VRT) for virtual cropping, resampling, kernel filtering, mosaicing
  • gdalwarp wrapper for reproject/resample/crop/mosaic
  • coordinate transformation
  • spatial reference systems
  • GDAL algorithms (dem_proc(), polygonize(), rasterize(), ...)
  • OGR vector utilities (ogrinfo(), ogr2ogr(), ogr_manage interface)
  • copy files/move/rename/delete raster and vector datasets
  • create/append to Seek-Optimized ZIP (SOZip)
  • abstraction of file system operations on URLs and cloud storage
  • Standard C binary file I/O through VSI (class VSIFile)

Additional functionality includes:

  • class RunningStats calculates mean and variance in one pass, and tracks the min, max, sum, and count (i.e., summary statistics on a data stream). The input data values are not stored in memory, so this class can be used to compute statistics for very large data streams.
  • class CmbTable identifies and counts unique combinations of integer values using a hash table.
  • combine() overlays multiple rasters so that a unique ID is assigned to each unique combination of input values. Pixel counts for each unique combination are obtained, and combination IDs are optionally written to an output raster.
  • calc() evaluates an R expression for each pixel in a raster layer or stack of layers. Individual pixel coordinates are available as variables in the R expression, as either x/y in the raster projected coordinate system or inverse projected longitude/latitude.
  • plot_raster() displays raster data using base R graphics.

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 GDAL version is recommended, e.g., >= 3.6.4. GDAL as of version 3.9 requires PROJ >= 6.3.1, but a more recent version of PROJ is also recommended. PROJ requires sqlite3, and libxml2 is required for the imported R package xml2.

On Ubuntu, recent versions of geospatial libraries can be installed from the ubuntugis-unstable PPA with the following commands:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt install libgdal-dev libgeos-dev libproj-dev libsqlite3-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, PROJ 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. For example, release 6104 of RTools 4.4 contains GDAL 3.8.4 and PROJ 9.3.1.

With RTools installed:

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

macOS

GDAL and PROJ can be installed with Homebrew:

brew install pkg-config gdal proj

Then configure.args may be needed:

# Install the development version from GitHub
remotes::install_github("USDAForestService/gdalraster", configure.args = "--with-proj-lib=$(brew --prefix)/lib/")

Caution seems warranted on macOS with regard to mixing a source installation with installation of binaries from CRAN.

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.

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

Documentation

Metadata

Version

1.11.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows