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

Returns a new instance of Gridder.

Parameters:

  • source_layer (OGR::Layer)

    The layer from which to use points and spatial reference for interpolating. Alternatively, use points to give specific point values for gridding.

  • dest_file_name (String)

    The path to output the gridded raster to.

  • gridder_options (GDAL::GridderOptions)
  • points (Array<Array<Float>>) (defaults to: nil)

    A 2D array of (x, y, z) points to use for gridding. Used for when you don’t want to use all points from source_layer.



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.

Returns:



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