Module: GDAL::RasterBand::Extensions
- Included in:
- GDAL::RasterBand
- Defined in:
- lib/gdal/extensions/raster_band/extensions.rb
Instance Method Summary collapse
- #each_overview ⇒ Enumerator
- #overviews ⇒ Array
-
#pixel_count ⇒ Integer
The total number of pixels in the raster band.
-
#projected_points ⇒ NArray
Each pixel of the raster projected using the dataset’s geo_transform.
- #to_a ⇒ Array
-
#to_na(to_data_type = nil) ⇒ NArray
Iterates through all lines and builds an NArray of pixels.
- #to_nna ⇒ Object
Instance Method Details
#each_overview ⇒ Enumerator
11 12 13 14 15 16 17 |
# File 'lib/gdal/extensions/raster_band/extensions.rb', line 11 def each_overview return enum_for(:each_overview) unless block_given? overview_count.times do |i| yield overview(i) end end |
#overviews ⇒ Array
20 21 22 |
# File 'lib/gdal/extensions/raster_band/extensions.rb', line 20 def overviews each_overview.to_a end |
#pixel_count ⇒ Integer
The total number of pixels in the raster band.
70 71 72 |
# File 'lib/gdal/extensions/raster_band/extensions.rb', line 70 def pixel_count x_size * y_size end |
#projected_points ⇒ NArray
Each pixel of the raster projected using the dataset’s geo_transform. The output NArray is a 3D array where the inner-most array is a the lat an lon, those are contained in an array per pixel line, and finally the outer array contains each of the pixel lines.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/gdal/extensions/raster_band/extensions.rb', line 52 def projected_points narray = GDAL._narray_from_data_type(data_type, 2, x_size, y_size) geo_transform = dataset.geo_transform y_size.times do |y_point| x_size.times do |x_point| coords = geo_transform.apply_geo_transform(x_point, y_point) narray[0, x_point, y_point] = coords[:x_geo] || 0 narray[1, x_point, y_point] = coords[:y_geo] || 0 end end narray end |
#to_a ⇒ Array
25 26 27 |
# File 'lib/gdal/extensions/raster_band/extensions.rb', line 25 def to_a read_lines_by_block.to_a end |
#to_na(to_data_type = nil) ⇒ NArray
Iterates through all lines and builds an NArray of pixels.
32 33 34 35 36 37 38 39 40 |
# File 'lib/gdal/extensions/raster_band/extensions.rb', line 32 def to_na(to_data_type = nil) narray = NArray.to_na(to_a) return narray unless to_data_type narray_type = GDAL._gdal_data_type_to_narray_type_constant(to_data_type) narray.to_type(narray_type) end |
#to_nna ⇒ Object
42 43 44 |
# File 'lib/gdal/extensions/raster_band/extensions.rb', line 42 def to_nna Numo::NArray[to_a] end |