Skip to contents

gdalraster is an interface to the Geospatial Data Abstraction Library (GDAL) for low level raster I/O. Calling signatures resemble those of the native C, C++ and Python APIs provided by the GDAL project. See https://gdal.org/api/ for details of the GDAL Raster API.

Details

Core functionality is contained in class GDALRaster and several related stand-alone functions:

Additional functionality includes:

  • RunningStats-class calculates mean and variance in one pass. The min, max, sum, and count are also tracked (efficient summary statistics on large data streams).

  • CmbTable-class implements a hash table for counting unique combinations of integer values.

  • 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. Supports single-band grayscale, RGB, color tables and color map functions (e.g., color ramp).

Author

GDAL is by: Frank Warmerdam, Even Rouault and others
(see https://github.com/OSGeo/gdal/graphs/contributors)

R interface/additional functionality: Chris Toney

Maintainer: Chris Toney <chris.toney at usda.gov>

Note

Documentation for GDALRaster-class and several wrapper functions borrows from the GDAL API documentation, (c) 1998-2024, Frank Warmerdam, Even Rouault, and others, MIT license.

Sample datasets included with the package are used in examples throughout the documentation. The sample data include LANDFIRE raster layers describing terrain, vegetation and wildland fuels (LF 2020 version), Landsat C2 Analysis Ready Data from USGS Earth Explorer, and Monitoring Trends in Burn Severity (MTBS) fire perimeters from 1984-2022. Metadata for the sample datasets are in inst/extdata/metadata.zip.

system.file() is used in the examples to access the sample datasets. This enables the code to run regardless of where R is installed. Users will normally give file names as a regular full path or relative to the current working directory.