gdalraster is an R interface to the Raster API of the Geospatial Data Abstraction Library (GDAL). Calling signatures resemble those of the native C, C++ and Python APIs provided by the GDAL project.
- manual creation of uninitialized raster datasets
- creation from existing raster as template
- read/set raster dataset parameters
- low-level I/O
- read/set color tables and raster attribute tables
- copy files/move/rename/delete datasets
- virtual raster (VRT) for virtual cropping, resampling, kernel filtering, mosaicing
gdalwarpwrapper for reproject/resample/crop/mosaic
- coordinate transformation
- spatial reference convenience functions
- several GDAL algorithms (
Additional functionality includes:
RunningStatscalculates 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.
CmbTableidentifies 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 should be useful in applications that need low-level raster I/O or prefer a direct GDAL API. The additional functionality is somewhat aimed at thematic data analysis but may have other utility. Comprehensive documentation is provided in the package and online.
Install the released version from CRAN with:
CRAN provides pre-compiled binary packages for Windows and macOS. These do not require any separate installation of external libraries for GDAL and PROJ.
GDAL (>= 2.4.0, built against GEOS), PROJ (>= 4.8.0), and sqlite3 are required.
On Ubuntu, recent versions of geospatial libraries can be installed from the ubuntugis-unstable PPA with the following commands:
-apt-repository ppa:ubuntugis/ubuntugis-unstable sudo add sudo apt update-dev libgeos-dev libproj-dev libsqlite3-devsudo apt install libgdal
The releases 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 gdalraster from CRAN:
Or install the development version from GitHub using package remotes:
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, revision 5863 of RTools 4.3 contains GDAL 3.7.2 and PROJ 9.3.0.
With RTools installed:
# Install the development version from GitHub remotes::install_github("USDAForestService/gdalraster")