Class: GDAL::Utils::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/gdal/utils/info.rb,
lib/gdal/utils/info/options.rb

Overview

Wrapper for gdalinfo using GDALInfo C API.

Defined Under Namespace

Classes: Options

Class Method Summary collapse

Class Method Details

.perform(dataset:, options: Options.new) ⇒ String

Perform the gdalinfo (GDALInfo) operation.

Examples:

Get info for a dataset.

dataset = GDAL::Dataset.open("my.tif", "r")
info = GDAL::Utils::Info.perform(dataset: dataset)
dataset.close

Get info for a dataset with options.

dataset = GDAL::Dataset.open("my.tif", "r")
info = GDAL::Utils::Info.perform(
  dataset: dataset,
  options: GDAL::Utils::Info::Options.new(options: ["-json", "-mdd", "all"])
)
dataset.close


30
31
32
33
34
35
36
37
# File 'lib/gdal/utils/info.rb', line 30

def self.perform(dataset:, options: Options.new)
  string, str_pointer = ::FFI::GDAL::Utils.GDALInfo(dataset.c_pointer, options.c_pointer)

  string
ensure
  # Returned string pointer must be freed with CPLFree().
  ::FFI::CPL::VSI.VSIFree(str_pointer)
end