Module: GDAL::Dataset::AlgorithmMethods
- Included in:
- GDAL::Dataset
- Defined in:
- lib/gdal/dataset/algorithm_methods.rb
Overview
Wrappers for Warp algorithm methods defined in gdal_alg.h.
Instance Method Summary collapse
-
#rasterize_geometries!(band_numbers, geometries, burn_values, transformer: nil, transform_arg: nil, **options, &progress_block) ⇒ Object
Rasterizes the geometric objects
geometries
into this raster dataset. - #rasterize_layers!(band_numbers, layers, burn_values, transformer: nil, transform_arg: nil, **options, &progress_block) ⇒ Object
-
#simple_image_warp(destination_dataset, transformer, transformer_arg_ptr, warp_options, band_numbers = 0, progress = nil) ⇒ GDAL::Dataset?
The new dataset or nil if the warping failed.
- #suggested_warp_output(transformer) ⇒ Hash{geo_transform: GDAL::GeoTransform, lines: Integer, pixels: Integer}
- #suggested_warp_output2(transformer) ⇒ Hash{extents: Hash{ min_x: Integer, min_y: Integer, max_x: Integer, max_y: Integer }, geo_transform: GDAL::GeoTransform, lines: Integer, pixels: Integer}
Instance Method Details
#rasterize_geometries!(band_numbers, geometries, burn_values, transformer: nil, transform_arg: nil, **options, &progress_block) ⇒ Object
Rasterizes the geometric objects geometries
into this raster dataset. transformer
can be nil as long as the geometries
are within the georeferenced coordinates of this raster’s dataset.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gdal/dataset/algorithm_methods.rb', line 24 def rasterize_geometries!(band_numbers, geometries, burn_values, transformer: nil, transform_arg: nil, **, &progress_block) if geo_transform.nil? && gcp_count.zero? raise "Can't rasterize geometries--no geo_transform or GCPs have been defined on the dataset." end = GDAL::Options.pointer() band_numbers = Array(band_numbers) geometries = Array(geometries) burn_values = Array(burn_values) band_numbers_ptr = FFI::MemoryPointer.new(:pointer, band_numbers.size) band_numbers_ptr.write_array_of_int(band_numbers) geometries_ptr = FFI::MemoryPointer.new(:pointer, geometries.size) geometries_ptr.write_array_of_pointer(geometries.map(&:c_pointer)) burn_values_ptr = FFI::MemoryPointer.new(:pointer, burn_values.size) burn_values_ptr.write_array_of_double(burn_values) FFI::GDAL::Alg.GDALRasterizeGeometries(@c_pointer, band_numbers.size, band_numbers_ptr, geometries.size, geometries_ptr, transformer, transform_arg, burn_values_ptr, , progress_block, nil) end |
#rasterize_layers!(band_numbers, layers, burn_values, transformer: nil, transform_arg: nil, **options, &progress_block) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/gdal/dataset/algorithm_methods.rb', line 75 def rasterize_layers!(band_numbers, layers, burn_values, transformer: nil, transform_arg: nil, **, &progress_block) = GDAL::Options.pointer() band_numbers = Array(band_numbers) log "band numbers: #{band_numbers}" layers = Array(layers) log "layers: #{layers}" burn_values = Array(burn_values) log "burn values: #{burn_values}" band_numbers_ptr = FFI::MemoryPointer.new(:pointer, band_numbers.size) band_numbers_ptr.write_array_of_int(band_numbers) log "band numbers ptr null? #{band_numbers_ptr.null?}" layers_ptr = FFI::MemoryPointer.new(:pointer, layers.size) layers_ptr.write_array_of_pointer(layers.map(&:c_pointer)) log "layers ptr null? #{layers_ptr.null?}" burn_values_ptr = FFI::MemoryPointer.new(:pointer, burn_values.size) burn_values_ptr.write_array_of_double(burn_values) log "burn value ptr null? #{burn_values_ptr.null?}" FFI::GDAL::Alg.GDALRasterizeLayers(@c_pointer, # hDS band_numbers.size, # nBandCount band_numbers_ptr, # panBandList layers.size, # nLayerCount layers_ptr, # pahLayers transformer, # pfnTransformer transform_arg, # pTransformerArg burn_values_ptr, # padfLayerBurnValues , # papszOptions progress_block, # pfnProgress nil) # pProgressArg end |
#simple_image_warp(destination_dataset, transformer, transformer_arg_ptr, warp_options, band_numbers = 0, progress = nil) ⇒ GDAL::Dataset?
Returns The new dataset or nil if the warping failed.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/gdal/dataset/algorithm_methods.rb', line 124 def simple_image_warp(destination_dataset, transformer, transformer_arg_ptr, , band_numbers = 0, progress = nil) destination_dataset_ptr = destination_dataset.c_pointer band_numbers = Array(band_numbers) log "band numbers: #{band_numbers}" bands_ptr = FFI::MemoryPointer.new(:pointer, band_numbers.size) bands_ptr.write_array_of_int(band_numbers) log "band numbers ptr null? #{bands_ptr.null?}" success = FFI::GDAL::Alg.GDALSimpleImageWarp(@c_pointer, destination_dataset_ptr, band_numbers.size, bands_ptr, transformer, transformer_arg_ptr, progress, nil, .c_pointer) success ? destination_dataset : nil end |
#suggested_warp_output(transformer) ⇒ Hash{geo_transform: GDAL::GeoTransform, lines: Integer, pixels: Integer}
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/gdal/dataset/algorithm_methods.rb', line 150 def suggested_warp_output(transformer) geo_transform = GDAL::GeoTransform.new pixels_ptr = FFI::MemoryPointer.new(:int) lines_ptr = FFI::MemoryPointer.new(:int) FFI::GDAL::Alg.GDALSuggestedWarpOutput( @c_pointer, transformer.function, transformer.c_pointer, geo_transform.c_pointer, pixels_ptr, lines_ptr ) { geo_transform: geo_transform, lines: lines_ptr.read_int, pixels: pixels_ptr.read_int } end |
#suggested_warp_output2(transformer) ⇒ Hash{extents: Hash{ min_x: Integer, min_y: Integer, max_x: Integer, max_y: Integer }, geo_transform: GDAL::GeoTransform, lines: Integer, pixels: Integer}
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/gdal/dataset/algorithm_methods.rb', line 175 def suggested_warp_output2(transformer) geo_transform = GDAL::GeoTransform.new pixels_ptr = FFI::MemoryPointer.new(:int) lines_ptr = FFI::MemoryPointer.new(:int) extents_ptr = FFI::MemoryPointer.new(:double, 4) = 0 # C code says this isn't used yet. FFI::GDAL::Alg.GDALSuggestedWarpOutput2( @c_pointer, transformer.function, transformer.c_pointer, geo_transform.c_pointer, pixels_ptr, lines_ptr, extents_ptr, ) extents_array = extents_ptr.read_array_of_double(4) extents = { min_x: extents_array[0], min_y: extents_array[1], max_x: extents_array[2], max_y: extents_array[3] } { extents: extents, geo_transform: geo_transform, lines: lines_ptr.read_int, pixels: pixels_ptr.read_int } end |