Skip to contents

gdalraster is an interface to the Geospatial Data Abstraction Library (GDAL) providing an R implementation of the GDAL Raster and Vector Data Models. Bindings also include the GDAL Geometry API, Spatial Reference Systems API, utilities and algorithms, methods for coordinate transformation, and the Virtual Systems Interface (VSI) API. Calling signatures resemble those of the native C, C++ and Python APIs provided by the GDAL project. See https://gdal.org/en/stable/api/ for details of the GDAL API.

Details

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

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

Bindings to the GDAL Geometry API, Spatial Reference Systems API, methods for coordinate transformation, the Virtual Systems Interface (VSI) API, general data management and system configuration are implemented in several 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 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 the API bindings borrows heavily from the GDAL documentation, (c) 1998-2025, Frank Warmerdam, Even Rouault, and others, MIT license.

Sample datasets included with the package are used in examples throughout the documentation. The sample data sources include:

Metadata for these sample datasets are in inst/extdata/metadata.zip and inst/extdata/ynp_features.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.

Temporary files are created in some examples which have cleanup code wrapped in dontshow{}. While the cleanup code is not shown in the documentation, note that this code runs by default if examples are run with example().