Open a GDAL dataset
Arguments
- path
Path to the dataset (file, URL, or connection string)
- update
Logical. If TRUE, open for update (read/write). Default FALSE.
- multidim
Logical. If TRUE, open in multidimensional mode (for NetCDF, Zarr, HDF5, etc.). Use get_root_group() to access the multidimensional structure. Default FALSE.
- options
Character vector of
KEY=VALUEopen options, orNULLfor none. These are the driver's own, and are how a source is told what its own metadata does not say: a CSV'sX_POSSIBLE_NAMES=lon, a raster'sOVERVIEW_LEVEL=2.driver_options()lists what a driver accepts andhas_open_option()asks about one by name. An option a driver does not recognise is a warning from GDAL, not an error.- drivers
Character vector of driver short names to try, or
NULLto let every driver try, which is the default. Naming the driver skips the probing and stops a second driver claiming a file the first should have had.character(0)is not the same asNULL: it would allow no driver at all, so it is rejected.
Examples
ds <- gdal_open(system.file("extdata/test.tif", package = "GDAL7"))
ds@raster_count
#> [1] 2
gdal_close(ds)
# Naming the driver, and reading the first overview instead of full size.
ds <- gdal_open(system.file("extdata/overviews.tif", package = "GDAL7"),
options = "OVERVIEW_LEVEL=0", drivers = "GTiff")
c(ds@raster_xsize, ds@raster_ysize)
#> [1] 256 128
gdal_close(ds)
if (FALSE) { # \dontrun{
# Multidimensional mode
ds <- gdal_open("/path/to/data.zarr", multidim = TRUE)
grp <- get_root_group(ds)
grp@mdarray_names
gdal_close(ds)
} # }