Returns all raster drivers supported by Ganos. Use can_read, can_export, and can_asfile to check whether a driver supports a specific operation before passing it to ST_CreateRast, ST_ImportFrom, ST_ExportTo, or ST_AsDatasetFile.
Syntax
setof record ST_RasterDrivers(out idx integer,
out short_name text,
out long_name text,
out can_read boolean,
out can_export boolean,
out can_asfile boolean,
out create_options text);Output parameters
| Parameter | Type | Description |
|---|---|---|
idx | integer | The ID of the driver. |
short_name | text | The abbreviated driver name. |
long_name | text | The full driver name. |
can_read | boolean | true: the driver's file formats are supported by ST_CreateRast and ST_ImportFrom. false: using these formats in ST_CreateRast or ST_ImportFrom returns an error. |
can_export | boolean | true: the driver's file formats are supported by ST_ExportTo. false: using these formats in ST_ExportTo returns an error. |
can_asfile | boolean | true: the driver's file formats are supported by ST_AsDatasetFile. false: using these formats in ST_AsDatasetFile returns an error. |
create_options | text | Driver-specific creation options for use in ST_ExportTo and ST_AsDatasetFile. Returned as XML in the format <CreationOptionList><Option name='...' type='...' .../></CreationOptionList>. Parse this field to discover available options such as compression format, chunking, and pixel type before building your export calls. |
Examples
Query a specific driver
The following example retrieves full details for the netCDF driver, including its create_options XML.
SELECT * FROM st_rasterdrivers()
WHERE short_name = 'netCDF';Example output:
idx | short_name | long_name | can_read | can_export | can_asfile | create_options
-----+------------+----------------------------+----------+------------+------------+----------------
36 | netCDF | Network Common Data Format | t | t | t | <CreationOptionList>...Parse create_options into a readable table
The create_options field returns XML. Use xpath() to extract option names and types as a structured table, which you can then reference when setting parameters in ST_ExportTo or ST_AsDatasetFile.
SELECT
(xpath('@name', opt))[1]::text AS option_name,
(xpath('@type', opt))[1]::text AS option_type,
(xpath('@description', opt))[1]::text AS description
FROM (
SELECT unnest(xpath('/CreationOptionList/Option', create_options::xml)) AS opt
FROM st_rasterdrivers()
WHERE short_name = 'netCDF'
) AS opts;Example output:
option_name | option_type | description
----------------+-------------+--------------------------------------------------
FORMAT | string-select |
COMPRESS | string-select |
ZLEVEL | int | DEFLATE compression level 1-9
WRITE_BOTTOMUP | boolean |
WRITE_GDAL_TAGS| boolean |
WRITE_LONLAT | string-select |
TYPE_LONLAT | string-select |
PIXELTYPE | string-select | only used in Create()
CHUNKING | boolean | define chunking when creating netcdf4 file
MULTIPLE_LAYERS| string-select | Behaviour regarding multiple vector layer creation
CONFIG_FILE | string | Path to a XML configuration file (or content inlined)Filter drivers by capability
Query drivers by which operations they support.
-- Drivers compatible with ST_ImportFrom and ST_CreateRast
SELECT short_name FROM st_rasterdrivers()
WHERE can_read = true;
-- Drivers compatible with ST_ExportTo
SELECT short_name FROM st_rasterdrivers()
WHERE can_export = true;
-- Drivers compatible with ST_AsDatasetFile
SELECT short_name FROM st_rasterdrivers()
WHERE can_asfile = true;