Class: GDAL::Gridder

Inherits:
Object
  • Object
show all
Includes:
PointExtracting, Logger
Defined in:
lib/gdal/extensions/gridder.rb,
lib/gdal/extensions/gridder/point_extracting.rb

Overview

Somewhat analogous to the gdal_grid utility.

Defined Under Namespace

Modules: PointExtracting

Constant Summary collapse

DESIRED_BUFFER_SIZE =
16 * 1024 * 1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PointExtracting

#points

Constructor Details

#initialize(source_layer, dest_file_name, gridder_options, points: nil) ⇒ Gridder



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/gdal/extensions/gridder.rb', line 36

def initialize(source_layer, dest_file_name, gridder_options, points: nil)
  @source_layer = source_layer
  @dest_file_name = dest_file_name
  @options = gridder_options

  @points = points
  @x_min = nil
  @x_max = nil
  @y_min = nil
  @y_max = nil
end

Instance Attribute Details

#gridGDAL::Grid (readonly)

Object used by for doing the actual grid work.



26
27
28
# File 'lib/gdal/extensions/gridder.rb', line 26

def grid
  @grid
end

Instance Method Details

#grid!Object

Does all of the things: gathers points from the associated Layer, processes the points according to associated GridderOptions, grids the points, and writes out the newly gridder raster.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/gdal/extensions/gridder.rb', line 51

def grid!
  dataset = build_dataset(@options.output_driver,
                          @dest_file_name,
                          @options.output_data_type,
                          @options.output_creation_options)

  grid_and_write(dataset.raster_band(1), dataset.geo_transform)

  if @options.algorithm_options[:no_data_value]
    dataset.raster_band(1).no_data_value = @options.algorithm_options[:no_data_value]
  end

  dataset.close
end