pub struct Driver { /* private fields */ }
Expand description
§Raster and Vector Driver API
One of GDAL’s major strengths is the vast number of data formats it’s able to work with. The GDAL Manual has a full list of available raster and vector drivers.
However, due to conditional compilation, not every driver listed will necessarily be available at runtime.
Therefore, one of the primary uses of the the Driver
is to inspect and load the available drivers.
(You can use gdalinfo --formats
to peruse this list from a CLI installation of GDAL)
Each driver has its own set of options, capabilities, and limitations. Furthermore, operations on one driver (e.g. copying a datasets) may or may not be available in another. So when working with a new dataset it is important to refer to the driver’s documentation for its capabilities.
See Driver
for more details.
Implementations§
source§impl Driver
impl Driver
sourcepub fn get_by_name(name: &str) -> Result<Driver>
👎Deprecated: Please use DriverManager::get_driver_by_name()
instead
pub fn get_by_name(name: &str) -> Result<Driver>
DriverManager::get_driver_by_name()
insteadReturns the driver with the given short name or Err
if not found.
sourcepub fn get(index: usize) -> Result<Driver>
👎Deprecated: Please use DriverManager::get_driver()
instead
pub fn get(index: usize) -> Result<Driver>
DriverManager::get_driver()
insteadReturns the driver with the given index, which must be less than the value returned by
Driver::count()
.
sourcepub fn count() -> usize
👎Deprecated: Please use DriverManager::count()
instead
pub fn count() -> usize
DriverManager::count()
insteadReturns the number of registered drivers.
sourcepub fn short_name(&self) -> String
pub fn short_name(&self) -> String
sourcepub fn create<P: AsRef<Path>>(
&self,
filename: P,
size_x: usize,
size_y: usize,
bands: usize,
) -> Result<Dataset>
pub fn create<P: AsRef<Path>>( &self, filename: P, size_x: usize, size_y: usize, bands: usize, ) -> Result<Dataset>
Create a new dataset of size (size_x
, size_y
) and bands
band count,
and u8
as the cell data type.
To specify an alternative data type (e.g. f32
), use create_with_band_type
.
See also: create_with_band_type_with_options
.
§Example
use gdal::DriverManager;
use gdal::raster::GdalDataType;
let d = DriverManager::get_driver_by_name("MEM")?;
let ds = d.create("in-memory", 64, 64, 3)?;
assert_eq!(ds.raster_count(), 3);
assert_eq!(ds.raster_size(), (64, 64));
assert_eq!(ds.rasterband(1)?.band_type(), GdalDataType::UInt8);
sourcepub fn create_with_band_type<T: GdalType, P: AsRef<Path>>(
&self,
filename: P,
size_x: usize,
size_y: usize,
bands: usize,
) -> Result<Dataset>
pub fn create_with_band_type<T: GdalType, P: AsRef<Path>>( &self, filename: P, size_x: usize, size_y: usize, bands: usize, ) -> Result<Dataset>
Create a new dataset of size (size_x
, size_y
) and bands
band count,
with cell data type specified by T
.
See also: create
, create_with_band_type_with_options
.
§Example
use gdal::DriverManager;
use gdal::raster::GdalDataType;
let d = DriverManager::get_driver_by_name("MEM")?;
let ds = d.create_with_band_type::<f64, _>("in-memory", 64, 64, 3)?;
assert_eq!(ds.raster_count(), 3);
assert_eq!(ds.raster_size(), (64, 64));
assert_eq!(ds.rasterband(1)?.band_type(), GdalDataType::Float64);
sourcepub fn create_with_band_type_with_options<T: GdalType, P: AsRef<Path>>(
&self,
filename: P,
size_x: usize,
size_y: usize,
bands: usize,
options: &RasterCreationOptions,
) -> Result<Dataset>
pub fn create_with_band_type_with_options<T: GdalType, P: AsRef<Path>>( &self, filename: P, size_x: usize, size_y: usize, bands: usize, options: &RasterCreationOptions, ) -> Result<Dataset>
Create a new dataset of size (size_x
, size_y
) and bands
band count,
with cell data type specified by T
and extended options specified via options
.
Per GDAL,
the set of legal options for options
is driver specific, and there is no way to query in advance to establish the valid ones.
See also: [RasterCreationOption
], create
, create_with_band_type
.
§Example
use gdal::DriverManager;
use gdal::raster::RasterCreationOptions;
use gdal::raster::GdalDataType;
use gdal::spatial_ref::SpatialRef;
let d = DriverManager::get_driver_by_name("BMP")?;
let options = RasterCreationOptions::from_iter(["WORLD_FILE=YES"]);
let mut ds = d.create_with_band_type_with_options::<u8, _>("/tmp/foo.bmp", 64, 64, 1, &options)?;
ds.set_spatial_ref(&SpatialRef::from_epsg(4326)?)?;
assert_eq!(ds.raster_count(), 1);
assert_eq!(ds.raster_size(), (64, 64));
assert_eq!(ds.rasterband(1)?.band_type(), GdalDataType::UInt8);
assert_eq!(ds.spatial_ref()?.auth_code()?, 4326);
sourcepub fn create_vector_only<P: AsRef<Path>>(&self, filename: P) -> Result<Dataset>
pub fn create_vector_only<P: AsRef<Path>>(&self, filename: P) -> Result<Dataset>
Convenience for creating a vector-only dataset from a compatible driver. Details
sourcepub fn delete<P: AsRef<Path>>(&self, filename: P) -> Result<()>
pub fn delete<P: AsRef<Path>>(&self, filename: P) -> Result<()>
Delete named dataset.
It is unwise to have open dataset handles on this dataset when it is deleted.
Calls GDALDeleteDataset()
sourcepub fn rename<P1: AsRef<Path>, P2: AsRef<Path>>(
&self,
new_filename: P1,
old_filename: P2,
) -> Result<()>
pub fn rename<P1: AsRef<Path>, P2: AsRef<Path>>( &self, new_filename: P1, old_filename: P2, ) -> Result<()>
Rename a dataset.
It is unwise to have open dataset handles on this dataset when it is being renamed.
Calls GDALRenameDataset()
sourcepub unsafe fn from_c_driver(c_driver: GDALDriverH) -> Driver
pub unsafe fn from_c_driver(c_driver: GDALDriverH) -> Driver
sourcepub unsafe fn c_driver(&self) -> GDALDriverH
pub unsafe fn c_driver(&self) -> GDALDriverH
Trait Implementations§
source§impl Metadata for Driver
impl Metadata for Driver
source§fn description(&self) -> Result<String>
fn description(&self) -> Result<String>
crate::Dataset
s, method returns this is the originating filename.
For crate::raster::RasterBand
s it is a description (if supported) or ""
. Read moresource§fn metadata_domains(&self) -> Vec<String>
fn metadata_domains(&self) -> Vec<String>
""
).
Specific “Major Object” types may have other conventionally recognized domains.
For example, in raster Dataset
s you may come across the domains
SUBDATASETS
, IMAGE_STRUCTURE
, RPC
, IMAGERY
, xml:
, etc. Read moresource§fn metadata_domain(&self, domain: &str) -> Option<Vec<String>>
fn metadata_domain(&self, domain: &str) -> Option<Vec<String>>
domain
. Returns None
if
domain is not defined.
Entries in the returned Vec<String>
are formatted as “Name=value” pairs Read more