Skip to content

Commit

Permalink
test cog generation
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotjordan committed Sep 30, 2024
1 parent 16d8c71 commit 369ac14
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/derivative_services/geo_derivatives/processors/gdal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def self.warp(in_path, out_path, options)
# @param out_path [String] processor output file path
# @param options [Hash] creation options
def self.compress(in_path, out_path, options)
execute "gdal_translate -q -ot Byte -a_srs #{options[:output_srid]} "\
"\"#{in_path}\" #{out_path} -co COMPRESS=JPEG -co JPEG_QUALITY=90"
execute "gdal_translate -q -a_srs #{options[:output_srid]} "\
"\"#{in_path}\" #{out_path}"
end

# Executes gdaladdo and gdal_translate commands. Used to add internal overviews
Expand All @@ -46,12 +46,18 @@ def self.compress(in_path, out_path, options)
# @param out_path [String] processor output file path
# @param options [Hash] creation options
def self.cloud_optimized_geotiff(in_path, out_path, _options)
execute("gdal_translate -q -expand rgb \"#{in_path}\" #{out_path} -ot Byte -of COG "\
"-a_nodata 256 -co COMPRESS=LZW")
# execute("gdal_translate -q -expand rgb \"#{in_path}\" #{out_path} -ot Byte -of COG "\
# "-a_nodata 256 -co COMPRESS=LZW")

execute("gdal_translate -q \"#{in_path}\" #{out_path} -of COG "\
"-a_nodata 256 -co COMPRESS=LZW -co TILING_SCHEME=GoogleMapsCompatible")
rescue StandardError
# Try without expanding rgb
execute("gdal_translate -q \"#{in_path}\" #{out_path} -ot Byte -of COG "\
"-a_nodata 256 -co COMPRESS=LZW")
# execute("gdal_translate -q \"#{in_path}\" #{out_path} -ot Byte -of COG "\
# "-a_nodata 256 -co COMPRESS=LZW")

execute("gdal_translate -q \"#{in_path}\" #{out_path} -of COG "\
"-a_nodata 256 -co COMPRESS=LZW -co TILING_SCHEME=GoogleMapsCompatible")
end

# Executes a gdal_rasterize command. Used to rasterize vector
Expand Down

0 comments on commit 369ac14

Please sign in to comment.