Module: NSWTopo::Import
- Includes:
- Raster
- Defined in:
- lib/nswtopo/layer/import.rb
Instance Method Summary collapse
Methods included from Raster
#create, #empty?, #filename, #render, #size_resolution, #to_s
Instance Method Details
#get_raster(temp_dir) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nswtopo/layer/import.rb', line 5 def get_raster(temp_dir) crop_path = temp_dir / "crop.tif" json = begin OS.gdalinfo "-json", @path rescue OS::Error raise "invalid raster file: #{@path}" end palette = JSON.parse(json)["bands"].any? do |band| "Palette" == band["colorInterpretation"] end projection = Projection.new(@path) args = ["-projwin", *@map.projwin(projection), @path, crop_path] args = ["-expand", "rgba", *args] if palette OS.gdal_translate *args return Numeric === @resolution ? @resolution : @map.get_raster_resolution(crop_path), crop_path end |