Class: Gdal_Band
- Inherits:
-
Gdal_Stuff
- Object
- Gdal_Stuff
- Gdal_Band
- Defined in:
- lib/gdal_helper.rb
Overview
Class wrapping up a gdal band.
Instance Method Summary collapse
-
#data_type ⇒ Object
returns the datatype.
-
#data_type_pretty ⇒ Object
returns the datatype as a string in a gdal like manner.
-
#initialize(band) ⇒ Gdal_Band
constructor
A new instance of Gdal_Band.
-
#read(start_x, start_y, width_x, width_y) ⇒ Object
Reads data.
-
#to_s ⇒ Object
converts to a string for display/print/other .to_s action.
-
#write(start_x, start_y, width_x, width_y, data) ⇒ Object
Writes data.
Methods inherited from Gdal_Stuff
#data_type_from_gdal, #data_type_to_gdal
Constructor Details
#initialize(band) ⇒ Gdal_Band
Returns a new instance of Gdal_Band.
58 59 60 |
# File 'lib/gdal_helper.rb', line 58 def initialize( band) @band = band end |
Instance Method Details
#data_type ⇒ Object
returns the datatype
72 73 74 |
# File 'lib/gdal_helper.rb', line 72 def data_type() data_type_from_gdal(@band.DataType) end |
#data_type_pretty ⇒ Object
returns the datatype as a string in a gdal like manner
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/gdal_helper.rb', line 77 def data_type_pretty() type_string = case(@band.DataType) when Gdal::Gdalconst::GDT_UNKNOWN; 'GDT_UNKNOWN' when Gdal::Gdalconst::GDT_BYTE; 'GDT_BYTE' when Gdal::Gdalconst::GDT_UINT16;'GDT_UINT16' when Gdal::Gdalconst::GDT_INT16;'GDT_INT16' when Gdal::Gdalconst::GDT_UINT32; 'GDT_UINT32' when Gdal::Gdalconst::GDT_INT32; 'GDT_INT32' when Gdal::Gdalconst::GDT_FLOAT32; 'IDT_FLOAT32' when Gdal::Gdalconst::GDT_FLOAT64; 'GDT_FLOAT64' when Gdal::Gdalconst::GDT_CINT16; 'GDT_CINT16' when Gdal::Gdalconst::GDT_CINT32; 'GDT_CINT32' when Gdal::Gdalconst::GDT_CFLOAT32; 'GDT_CFLOAT32' when Gdal::Gdalconst::GDT_CFLOAT64; 'GDT_CFLOAT64' end type_string end |
#read(start_x, start_y, width_x, width_y) ⇒ Object
Reads data
62 63 64 |
# File 'lib/gdal_helper.rb', line 62 def read(start_x, start_y, width_x, width_y) return unpack(width_y*width_x, @band.read_raster(start_x,start_y,width_x,width_y)) end |
#to_s ⇒ Object
converts to a string for display/print/other .to_s action
96 97 98 |
# File 'lib/gdal_helper.rb', line 96 def to_s "#{data_type_pretty}" end |
#write(start_x, start_y, width_x, width_y, data) ⇒ Object
Writes data
67 68 69 |
# File 'lib/gdal_helper.rb', line 67 def write(start_x, start_y, width_x, width_y, data) return @band.write_raster(start_x,start_y,width_x,width_y, pack(data)) end |