Class: GDAL::GridderOptions

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gdal/extensions/gridder_options.rb

Overview

Object to be used with a Gridder.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm_type) ⇒ GridderOptions

Returns a new instance of GridderOptions.

Parameters:



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/gdal/extensions/gridder_options.rb', line 123

def initialize(algorithm_type)
  # Options with defaults
  @output_data_type = :GDT_Float64
  @output_format = "GTiff"
  @output_size = { width: 256, height: 256 }

  # Options without defaults
  @input_clipping_geometry = nil
  @output_x_extent = {}
  @output_y_extent = {}
  @output_projection = nil
  @output_creation_options = {}
  @progress_formatter = nil

  @grid = GDAL::Grid.new(algorithm_type, data_type: @output_data_type)
end

Instance Attribute Details

#gridGDAL::Grid (readonly)

Object used by the GDAL::Gridder for doing the actual grid work.

Returns:



114
115
116
# File 'lib/gdal/extensions/gridder_options.rb', line 114

def grid
  @grid
end

#input_clipping_geometryOGR::Geometry

Use for filtering out input points; any input points from the layer that fall within this boundary will be excluded from the gridding process. Note that this does not clip the output raster.

Replaces gdal_grid’s -clipsrc option.

Returns:



38
39
40
# File 'lib/gdal/extensions/gridder_options.rb', line 38

def input_clipping_geometry
  @input_clipping_geometry
end

#input_field_nameString

Name of field attribute to extract from each feature to use for Z values.

Returns:



18
19
20
# File 'lib/gdal/extensions/gridder_options.rb', line 18

def input_field_name
  @input_field_name
end

#output_creation_optionsHash

Driver-specific options to pass to the Driver when creating the raster. Check out GDAL documentation for the driver you’re specifying (specified here through #output_format) to see what options you have available.

Correlates to gdal_grid option -co.

Returns:

  • (Hash)


49
50
51
# File 'lib/gdal/extensions/gridder_options.rb', line 49

def output_creation_options
  @output_creation_options
end

#output_data_typeFFI::GDAL::GDAL::DataType

Data type of the output raster values.

Correlates to gdal_grid option -ot.



108
109
110
# File 'lib/gdal/extensions/gridder_options.rb', line 108

def output_data_type
  @output_data_type
end

#output_formatString

The Driver name to use for creating the output raster.

Correlates to gdal_grid option -of.

Returns:



57
58
59
# File 'lib/gdal/extensions/gridder_options.rb', line 57

def output_format
  @output_format
end

#output_projectionOGR::SpatialReference

The SpatialReference to use for the output raster’s Dataset#projection. If one isn’t given, the GDAL::Gridder will try to use the one from the source layer.

Correlates to gdal_grid option -a_srs.



83
84
85
# File 'lib/gdal/extensions/gridder_options.rb', line 83

def output_projection
  @output_projection
end

#output_sizeHash{width: Number, height: Number} #output_size=(width_height_array) ⇒ Hash{width: Number, height: Number} #output_size=(width_height_hash) ⇒ Hash{width: Number, height: Number}

Dimensions to output the raster in.

Correlates to gdal_grid option -outsize.

Overloads:

  • #output_size=(width_height_array) ⇒ Hash{width: Number, height: Number}

    Sets the output Hash using a 2-element Array.

    Parameters:

    • width_height_array (Array<Float>)

      A 2-element Array specifying the width and height of the output raster.

  • #output_size=(width_height_hash) ⇒ Hash{width: Number, height: Number}

    Sets the output Hash using a similar input Hash.

    Parameters:

    • width_height_hash (Hash{width => Number, height => Number})

      A Hash with :width and :height keys, specifying the width and height of the output raster.

Returns:

  • (Hash{width: Number, height: Number})


100
101
102
# File 'lib/gdal/extensions/gridder_options.rb', line 100

def output_size
  @output_size
end

#output_x_extentHash{min: Number, max: Number}

The minimum and maximum X coordinates for the output raster.

Correlates to gdal_grid option -txe.

Returns:

  • (Hash{min: Number, max: Number})


65
66
67
# File 'lib/gdal/extensions/gridder_options.rb', line 65

def output_x_extent
  @output_x_extent
end

#output_y_extentHash{min: Number, max: Number}

The minimum and maximum Y coordinates for the output raster.

Correlates to gdal_grid option -tye.

Returns:

  • (Hash{min: Number, max: Number})


73
74
75
# File 'lib/gdal/extensions/gridder_options.rb', line 73

def output_y_extent
  @output_y_extent
end

#progress_formatterProc

Custom progress output Proc, passed on to GDAL::Grid#create. This must follow semantics imposed by FFI::GDAL::GDAL.ProgressFunc.

This option doesn’t exist in gdal_grid; you only get their output format or no output at all (using -q).

Returns:

  • (Proc)


28
29
30
# File 'lib/gdal/extensions/gridder_options.rb', line 28

def progress_formatter
  @progress_formatter
end

Instance Method Details

#algorithm_optionsFFI::Struct

Object used by the GDAL::Gridder for doing the actual grid work.

Returns:

  • (FFI::Struct)

    One of the FFI::GDAL grid algorithm Options objects.



120
# File 'lib/gdal/extensions/gridder_options.rb', line 120

def_delegator :@grid, :algorithm_options, :algorithm_options

#output_data_type_sizeInteger

Returns:



163
164
165
# File 'lib/gdal/extensions/gridder_options.rb', line 163

def output_data_type_size
  GDAL::DataType.size(@output_data_type) / 8
end

#output_driverGDAL::Driver

The Driver, based on #output_format to use for creating the output raster.

Returns:



182
183
184
# File 'lib/gdal/extensions/gridder_options.rb', line 182

def output_driver
  @output_driver ||= GDAL::Driver.by_name(@output_format)
end