Struct MDArray

Source
pub struct MDArray<'a> { /* private fields */ }
Expand description

Represent an MDArray in a Group

This object carries the lifetime of the Group that contains it. This is necessary to prevent the Group from being dropped before the mdarray.

Implementations§

Source§

impl<'a> MDArray<'a>

Source

pub unsafe fn from_c_mdarray_and_group( _group: &'a Group<'_>, c_mdarray: GDALMDArrayH, ) -> Self

Create a MDArray from a wrapped C pointer

§Safety

This method operates on a raw C pointer

Source

pub unsafe fn from_c_mdarray_and_dimension( _dimension: &'a Dimension<'_>, c_mdarray: GDALMDArrayH, ) -> Self

Create a MDArray from a wrapped C pointer

§Safety

This method operates on a raw C pointer

Source

pub fn num_dimensions(&self) -> usize

Source

pub fn num_elements(&self) -> u64

Source

pub fn dimensions(&self) -> Result<Vec<Dimension<'_>>>

Source

pub fn datatype(&self) -> ExtendedDataType

Source

pub fn read_into_slice<T: Copy + GdalType>( &self, buffer: &mut [T], array_start_index: Vec<u64>, count: Vec<usize>, ) -> Result<()>

Wrapper for GDALMDArrayRead

§Params
  • buffer - Mutable buffer to read into
  • array_start_index - Values representing the starting index to read in each dimension (in [0, aoDims[i].GetSize()-1] range). Array of GetDimensionCount() values. Must not be empty, unless for a zero-dimensional array.
  • count - Values representing the number of values to extract in each dimension. Array of GetDimensionCount() values. Must not be empty, unless for a zero-dimensional array.
Source

pub fn read_as<T: Copy + GdalType>( &self, array_start_index: Vec<u64>, count: Vec<usize>, ) -> Result<Vec<T>>

Read a Vec<T> from this band, where T implements GdalType.

§Arguments
  • array_start_index - Values representing the starting index to read in each dimension (in [0, aoDims[i].GetSize()-1] range). Array of GetDimensionCount() values. Must not be empty, unless for a zero-dimensional array.
  • count - Values representing the number of values to extract in each dimension. Array of GetDimensionCount() values. Must not be empty, unless for a zero-dimensional array.
Source

pub fn read_as_array<T: Copy + GdalType + Debug>( &self, array_start_index: Vec<u64>, count: Vec<usize>, array_size: Vec<usize>, ) -> Result<ArrayD<T>>

Available on crate feature ndarray only.

Read an ArrayD<T> from this band. T implements GdalType.

§Arguments
  • window - the window position from top left
  • window_size - the window size (GDAL will interpolate data if window_size != array_size)
  • array_size - the desired size of the ‘Array’
  • e_resample_alg - the resample algorithm used for the interpolation
§Notes

The Matrix shape is (rows, cols) and raster shape is (cols in x-axis, rows in y-axis).

Source

pub fn read_as_string_array(&self) -> Result<Vec<String>>

Read MDArray as one-dimensional string array

Source

pub fn spatial_reference(&self) -> Result<SpatialRef>

Source

pub fn no_data_value_as_double(&self) -> Option<f64>

Source

pub fn unit(&self) -> String

Source

pub fn attribute(&self, name: &str) -> Result<Attribute>

Source

pub fn get_statistics( &self, force: bool, is_approx_ok: bool, ) -> Result<Option<MdStatisticsAll>>

Fetch statistics.

Returns the minimum, maximum, mean and standard deviation of all pixel values in this array.

If force is false results will only be returned if it can be done quickly (i.e. without scanning the data). If force is false and results cannot be returned efficiently, the method will return None.

When cached statistics are not available, and force is true, ComputeStatistics() is called.

Note that file formats using PAM (Persistent Auxiliary Metadata) services will generally cache statistics in the .aux.xml file allowing fast fetch after the first request.

This methods is a wrapper for GDALMDArrayGetStatistics.

TODO: add option to pass progress callback (pfnProgress)

Trait Implementations§

Source§

impl<'a> Debug for MDArray<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for MDArray<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for MDArray<'a>

§

impl<'a> RefUnwindSafe for MDArray<'a>

§

impl<'a> !Send for MDArray<'a>

§

impl<'a> !Sync for MDArray<'a>

§

impl<'a> Unpin for MDArray<'a>

§

impl<'a> UnwindSafe for MDArray<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.