Bindings to the GDAL API
gdalraster-package.Rd
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:
GDALRaster-class
is an exposed C++ class that allows opening a raster dataset and calling methods on theGDALDataset
,GDALDriver
andGDALRasterBand
objects in the underlying API (e.g., get/set parameters, read/write pixel data).raster creation:
create()
,createCopy()
,rasterFromRaster()
,translate()
,getCreationOptions()
,validateCreationOptions()
virtual raster:
autoCreateWarpedVRT()
,buildVRT()
,rasterToVRT()
reproject/resample/crop/mosaic:
warp()
algorithms:
dem_proc()
,fillNodata()
,footprint()
,polygonize()
,rasterize()
,sieveFilter()
,GDALRaster$getChecksum()
raster attribute tables:
buildRAT()
,displayRAT()
,GDALRaster$getDefaultRAT()
,GDALRaster$setDefaultRAT()
geotransform conversion:
apply_geotransform()
,get_pixel_line()
,inv_geotransform()
,pixel_extract()
data type convenience functions:
dt_size()
,dt_is_complex()
,dt_is_integer()
,dt_is_floating()
,dt_is_signed()
,dt_union()
,dt_union_with_value()
,dt_find()
,dt_find_for_value()
Core vector functionality is contained in class GDALVector
and several
related stand-alone functions:
GDALVector-class
is an exposed C++ class that allows opening a vector dataset and calling methods on a specifiedOGRLayer
object that it contains (e.g., obtain layer information, set attribute and/or spatial filters, read/write feature data).OGR vector utilities:
ogrinfo()
,ogr2ogr()
,ogr_reproject()
,ogr_define
,ogr_manage
,ogr_proc()
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:
Geometry API:
bbox_from_wkt()
,bbox_to_wkt()
,bbox_intersect()
,bbox_union()
,bbox_transform()
,g_factory
,g_query
,g_binary_pred
,g_binary_op
,g_measures
,g_unary_op
,g_coords()
,g_envelope()
,g_make_valid()
,g_swap_xy()
,g_transform()
,g_wk2wk()
,geos_version()
Spatial Reference Systems API:
srs_convert
,srs_query
coordinate transformation:
transform_xy()
,inv_project()
,transform_bounds()
data management:
addFilesInZip()
,copyDatasetFiles()
,deleteDataset()
,renameDataset()
,bandCopyWholeRaster()
,identifyDriver()
,inspectDataset()
Virtual Systems Interface API:
VSIFile-class
,vsi_clear_path_options()
,vsi_copy_file()
,vsi_curl_clear_cache()
,vsi_get_disk_free_space()
,vsi_get_file_metadata()
,vsi_get_fs_options()
,vsi_get_fs_prefixes()
,vsi_is_local()
,vsi_mkdir()
,vsi_read_dir()
,vsi_rename()
,vsi_rmdir()
,vsi_set_path_option()
,vsi_stat()
,vsi_supports_rnd_write()
,vsi_supports_seq_write()
,vsi_sync()
,vsi_unlink()
,vsi_unlink_batch()
GDAL configuration:
gdal_version
,gdal_compute_version()
,gdal_formats()
,get_cache_used()
,get_cache_max()
,set_cache_max()
,get_config_option()
,set_config_option()
,get_num_cpus()
,get_usable_physical_ram()
,has_spatialite()
,http_enabled()
,push_error_handler()
,pop_error_handler()
,dump_open_datasets()
PROJ configuration:
proj_version()
,proj_search_paths()
,proj_networking()
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 Rgraphics
. 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>
See also
GDAL Raster Data Model:
https://gdal.org/en/stable/user/raster_data_model.html
Raster driver descriptions:
https://gdal.org/en/stable/drivers/raster/index.html
Geotransform tutorial:
https://gdal.org/en/stable/tutorials/geotransforms_tut.html
GDAL Vector Data Model:
https://gdal.org/en/stable/user/vector_data_model.html
Vector driver descriptions:
https://gdal.org/en/stable/drivers/vector/index.html
GDAL Virtual File Systems:
https://gdal.org/en/stable/user/virtual_file_systems.html
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:
LANDFIRE raster layers describing terrain, vegetation and wildland fuels (LF 2020 version)
Landsat C2 Analysis Ready Data from USGS Earth Explorer
Monitoring Trends in Burn Severity (MTBS) fire perimeters from 1984-2022
NLCD Tree Canopy Cover produced by USDA Forest Service
National Park Service Open Data vector layers for roads and points-of-interest
Montana State Library boundary layer for Yellowstone National Park
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()
.