Struct gdal::Driver

source ·
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

source

pub fn get_by_name(name: &str) -> Result<Driver>

👎Deprecated: Please use DriverManager::get_driver_by_name() instead

Returns the driver with the given short name or Err if not found.

source

pub fn get(index: usize) -> Result<Driver>

👎Deprecated: Please use DriverManager::get_driver() instead

Returns the driver with the given index, which must be less than the value returned by Driver::count().

source

pub fn count() -> usize

👎Deprecated: Please use DriverManager::count() instead

Returns the number of registered drivers.

source

pub fn short_name(&self) -> String

Return the short name of a driver.

For the GeoTIFF driver, this is “GTiff”

See also: long_name.

source

pub fn long_name(&self) -> String

Return the short name of a driver.

For the GeoTIFF driver, this is “GeoTIFF”

See also: short_name.

source

pub fn create<P: AsRef<Path>>( &self, filename: P, size_x: isize, size_y: isize, bands: isize ) -> 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);
source

pub fn create_with_band_type<T: GdalType, P: AsRef<Path>>( &self, filename: P, size_x: isize, size_y: isize, bands: isize ) -> 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);
source

pub fn create_with_band_type_with_options<T: GdalType, P: AsRef<Path>>( &self, filename: P, size_x: isize, size_y: isize, bands: isize, options: &[RasterCreationOption<'_>] ) -> 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::RasterCreationOption;
use gdal::raster::GdalDataType;
use gdal::spatial_ref::SpatialRef;
let d = DriverManager::get_driver_by_name("BMP")?;
let options = [
    RasterCreationOption {
        key: "WORLDFILE",
        value: "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);
source

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

source

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()

source

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()

source

pub unsafe fn from_c_driver(c_driver: GDALDriverH) -> Driver

Creates a new Driver object by wrapping a C pointer

Safety

This method operates on a raw C pointer

source

pub unsafe fn c_driver(&self) -> GDALDriverH

Returns the wrapped C pointer

Safety

This method returns a raw C pointer

Trait Implementations§

source§

impl Metadata for Driver

source§

fn description(&self) -> Result<String>

For most crate::Datasets, method returns this is the originating filename. For crate::raster::RasterBands it is a description (if supported) or "". Read more
source§

fn metadata_domains(&self) -> Vec<String>

Metadata in GDAL is partitioned into namespaces, knows as “domains” in the GDAL Data Model. GDAL types with metadata (a.k.a. “Major Objects”) have a default or “root” domain identified by the empty string (""). Specific “Major Object” types may have other conventionally recognized domains. For example, in raster Datasets you may come across the domains SUBDATASETS, IMAGE_STRUCTURE, RPC, IMAGERY, xml:, etc. Read more
source§

fn metadata_domain(&self, domain: &str) -> Option<Vec<String>>

Get all the metadata values within the given domain. Returns None if domain is not defined. Entries in the returned Vec<String> are formatted as “Name=value” pairs Read more
source§

fn metadata_item(&self, key: &str, domain: &str) -> Option<String>

Get a single metadata entry, as indicated by key and domain. Read more
source§

fn set_metadata_item( &mut self, key: &str, value: &str, domain: &str ) -> Result<()>

Set a metadata item in given domain at given key. Read more
source§

fn set_description(&mut self, description: &str) -> Result<()>

For Datasets this sets the dataset name; normally application code should not set the “description” for GDALDatasets. For RasterBands it is actually a description (if supported) or "".
source§

fn metadata(&self) -> MetadataIter<'_>where Self: Sized,

Get an iterator over metadata entries, across all domains. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Driver

§

impl !Send for Driver

§

impl !Sync for Driver

§

impl Unpin for Driver

§

impl UnwindSafe for Driver

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.