Skip to contents

The package

GDAL7 GDAL7-package
GDAL7: Modern GDAL Bindings for R Using S7

Classes

Every GDAL handle reaches R as one of these S7 classes. Their accessors are properties rather than get_/set_ functions, so a dataset’s size, projection and geotransform are read with @ and set the same way where GDAL allows it.

GDALMajorObject()
GDAL MajorObject class
GDALDataset()
GDAL Dataset class
GDALDriver()
GDALDriver class
GDALRasterBand()
GDALRasterBand class
GDALLayer()
GDAL layer class
GDALGroup()
GDALGroup class
GDALMDArray()
GDALMDArray class

Open and close a dataset

Opening is where a source is told what its own metadata does not say, and closing is where a written dataset is actually finished. A dataset closes itself when R garbage collects it, so gdal_close() is for closing it sooner rather than for avoiding a leak.

gdal_open()
Open a GDAL dataset
gdal_close()
Close a GDAL dataset
gdal_flush()
Write out everything held in memory
gdal_info()
Summarise a dataset in one call
mark_suppress_on_close()
MarkSuppressOnClose
get_thread_safe_dataset() is_thread_safe()
A view of a dataset that several threads may read at once
get_close_reports_progress()
GetCloseReportsProgress

Drivers

What this build of GDAL can read and write, and what a given driver will accept. Asking the library beats trusting a version number, because a driver is only present if it was compiled in.

gdal_drivers()
Every driver this GDAL has
gdal_get_driver_count()
Get the number of registered GDAL drivers
gdal_get_driver()
Get a driver by index
gdal_get_driver_by_name()
Get a driver by name
get_driver()
Get the driver that opened a dataset
driver_options()
What a driver will accept
has_open_option()
Check if driver has an open option
validate_creation_options()
Check creation options against a driver
test_capability()
Test driver capability

Raster I/O

read_raster() is one call onto GDALRasterIOEx: a fractional source window, an output size chosen independently of it, a resampling algorithm, and the values read straight into the R vector of the requested type. Overviews are reached explicitly when a band’s own pyramid is wanted. warp_raster() reprojects onto a grid with GDAL’s warp API, into bands or a nativeRaster.

read_raster()
Read a window of raster data
warp_raster()
Warp a dataset onto a grid
advise_read()
Tell GDAL what is about to be read
get_raster_band()
Get a raster band from a dataset
get_overview()
Get one overview of a band
flush_cache()
FlushCache
clear_statistics()
ClearStatistics

Vector

Features come back over GDAL’s own Arrow stream rather than feature by feature, so a layer read is a columnar transfer. The filters and the SQL are set on the layer before the stream is asked for, and transactions wrap edits on drivers that support them.

read_vector()
Read a vector layer into a data frame
get_layer()
Get a layer from a dataset
feature_count()
Count the features of a layer
get_extent()
The bounding box of a layer
set_filter()
Restrict which features a layer returns
reset_reading()
ResetReading
arrow_stream()
The Arrow stream of a layer
release_arrow_stream()
Give an Arrow stream back to its layer
execute_sql()
Run an SQL statement against a dataset
abort_sql()
AbortSQL
start_transaction()
StartTransaction
commit_transaction()
CommitTransaction
rollback_transaction()
RollbackTransaction
get_field_domain_names()
GetFieldDomainNames
delete_field_domain()
DeleteFieldDomain
get_relationship_names()
GetRelationshipNames
delete_relationship()
DeleteRelationship

Multidimensional

GDAL’s multidimensional model, for the sources that have more than two dimensions: netCDF, Zarr, HDF5. read_mdarray() returns dim in the order the values arrive in, which is the reverse of GDAL’s own dimension order; the array’s dimensions property still reports GDAL’s.

get_root_group()
Get root group from a multidimensional dataset
open_group()
Open a subgroup from a group
open_mdarray()
Open an array from a group
read_mdarray()
Read from a multidimensional array
as_altarr()
A GDAL array or band as a lazy R array
mdarray_info()
Everything about an array in one call
get_view()
Take a view of an array
as_classic_dataset()
See a two-dimensional slice of an array as an ordinary raster
as_mdarray()
AsMDArray

Algorithms and pipelines

GDAL’s own algorithm registry, the C API behind the gdal command line. A pipeline is named and its arguments passed as a list, so anything the installed GDAL registers is callable without a wrapper being written for it here. Not every build has it: ask gdal_has_algorithms() first.

gdal_has_algorithms()
Whether this GDAL has algorithms to run
gdal_algorithms()
List GDAL's algorithms
gdal_algorithm_info()
Describe one of GDAL's algorithms
gdal_run()
Run one of GDAL's algorithms

Creating and writing

The write side. A dataset is created empty and filled, or copied from an existing one in a single driver call, and creation options are validated against the driver rather than discovered by the write failing.

gdal_create()
Create a new raster dataset
gdal_create_copy()
Copy a dataset, in another format or with other options
gdal_delete()
Delete a dataset
write_raster()
Write a raster window
write_vector()
Write a data frame to a vector dataset
add_band()
AddBand
create_mask_band()
CreateMaskBand

Metadata

Metadata on any major object, in GDAL’s domains. The same six functions serve a dataset, a band, a layer, a group and an array.

get_metadata_list()
GetMetadata_List
get_metadata_dict()
GetMetadata_Dict
get_metadata_item()
GetMetadataItem
set_metadata()
SetMetadata
set_metadata_2()
SetMetadata (overload 2)
set_metadata_item()
SetMetadataItem

Coordinates and extents

Moving between pixel space, projected space and another coordinate reference system. transform_extent() walks the edges of a box rather than transforming its four corners, which is the difference between a correct box and a wrong one wherever an edge is not monotonic.

crs_to_wkt()
A coordinate reference system as WKT
pixel_to_xy() xy_to_pixel()
Convert between pixel and georeferenced coordinates
transform_extent()
Move an extent between coordinate reference systems

File systems

GDAL’s virtual file system, which is how a path into a zip, an S3 bucket or an HTTP range request is read like a local file. These work on any /vsi… path as well as on ordinary ones.

vfs_list() vfs_stat() vfs_exists()
GDAL's virtual file systems
vfs_read_file() vfs_write_file()
Read and write bytes over a GDAL virtual file system
vfs_unlink() vfs_mkdir() vfs_rmdir() vfs_rename() vfs_copy()
Change a GDAL virtual file system

Configuration and capabilities

What this build can do, and how to change how it behaves. GDAL’s configuration options are process-global, so with_gdal_config() sets them for one expression and restores them afterwards.

gdal_config() gdal_config_options() with_gdal_config()
GDAL's configuration options
gdal7_capabilities()
What this build of GDAL7 can reach
gdal_release()
The GDAL library GDAL7 is running against
gdal_constants()
GDAL's integer constants
gdal_data_types() gdal_color_interpretations()
GDAL enum tables
gdal_string_constants()
GDAL's string constants