package gdal

  1. Overview
  2. Docs

Raster Bands

type c
type ('v, 'e) t = c * ('v, 'e) Bigarray.kind
val t : c Ctypes.typ
val to_ba_kind : ('v, 'e) t -> ('v, 'e) Bigarray.kind

to_ba_kind t returns the Bigarray.kind matching t.

module Data : sig ... end
exception IO_error
exception Invalid_dimensions
val get_size : (_, _) t -> int * int

get_size t returns the (x, y) dimensions in pixels.

val get_data_type : c -> [ `byte | `uint16 | `int16 | `uint32 | `int32 | `float32 | `float64 | `unknown | `unhandled ]

get_data_type t returns the data type of the given raster band.

  • returns

    `unknown if GDAL does not know the data type

  • returns

    `unhandled if the data type is recognized by GDAL but unhandled by the OCaml bindings.

val get_band_number : (_, _) t -> int option

get_band_number t returns the index of t in its dataset or None if the index is unknown.

val read : ?offset:(int * int) -> ?size:(int * int) -> ?pixel_spacing:int -> ?line_spacing:int -> ?buffer_size:(int * int) -> (_, _) t -> ('v, 'e) Data.t -> ('v, 'e, Bigarray.c_layout) Bigarray.Array2.t

read t kind reads the values from t as kind values.

val write : ?offset:(int * int) -> ?size:(int * int) -> ?pixel_spacing:int -> ?line_spacing:int -> (_, _) t -> ('v, 'e) Data.t -> ('v, 'e, Bigarray.c_layout) Bigarray.Array2.t -> unit

write t kind data writes the values from t as kind values.

val fill : ?imaginary:float -> (_, _) t -> float -> unit

file ?imaginary t real sets all values in t to real. If t holds complex numbers then imaginary can be specified as well.

  • parameter imaginary

    defaults to 0.0.

val get_description : (_, _) t -> string

get_description t returns the description of the current band. If no description exists then the returned string will be empty.

val get_no_data_value : (_, _) t -> float option

get_no_data_value t returns the value representing no/missing data in band t, or None if no such value is set.

val set_description : (_, _) t -> string -> unit

set_description t desc sets the description of t to desc.

val set_no_data_value : (_, _) t -> float -> unit

set_no_data_value t x defines x as representing no/missing data in band t.

val iter : ('v, _) t -> (int -> int -> 'v -> 'v) -> unit

iter t f applies f to every value in t then assigns the result back to the same point in t.

  • parameter f

    gets three arguments: column, row and the value at this location in the band.

val iter_read : ('v, _) t -> (int -> int -> 'v -> unit) -> unit

iter_read t f calls f with every value in t.

  • parameter f

    gets three arguments: column, row for the pixel offset within the band and the value at this offset.

val iter_write : ('v, _) t -> (int -> int -> 'v) -> unit

iter_write t f calls f with every pixel offset in t. The result of f is written back to t at the current offset.

  • parameter f

    gets three arguments: column, row for the pixel offset within the band.

val itera : ('v1, _) t array -> ('v2, _) t -> (int -> int -> 'v1 array -> 'v2 -> 'v2) -> unit

itera src dst f acts like iter except that it applies f to matching pixels in each raster in src and dst, writing the result of f back to dst. All bands in src and dst must have the same overall dimensions and the same block size.

  • parameter f

    gets three arguments: column, row and the src value and dst values at this location in the bands.

val itera_read : ('v1, _) t array -> ('v2, _) t -> (int -> int -> 'v1 array -> 'v2 -> unit) -> unit

itera_read src dst f is like itera except that no values are written back to dst.

val itera_write : ('v1, _) t array -> ('v2, _) t -> (int -> int -> 'v1 array -> 'v2) -> unit

itera_write t f is like itera except that no values are read from dst.

val fold : ('v, _) t -> (int -> int -> 'v -> 'accu -> 'accu) -> 'accu -> 'accu

fold t f init folds over the pixels in t with f.

val copy : ?options:string list -> src:(_, _) t -> dst:(_, _) t -> unit

copy ?options ~src ~dst copies the contents of src to dst. GDAL will perform any data conversion necessary.

module Block : sig ... end