{"id":345,"date":"2024-10-10T22:13:17","date_gmt":"2024-10-10T22:13:17","guid":{"rendered":"https:\/\/www.acugis.com\/gis-tutorials\/?page_id=345"},"modified":"2024-10-10T22:13:17","modified_gmt":"2024-10-10T22:13:17","slug":"convert-geotiff-to-cog","status":"publish","type":"page","link":"https:\/\/www.acugis.com\/gis-tutorials\/geoserver\/convert-geotiff-to-cog\/","title":{"rendered":"Convert GeoTIFF to COG"},"content":{"rendered":"\n<p>This post will cover converting a GeoTIFF to Cloud Optimized GeoTIFF (COG)<\/p>\n\n\n\n<p>For our example, let&#8217;s use the GeoTIFF file FAA_UTM18N_NAD83.tif from the U.S. Geological Survey.<\/p>\n\n\n\n<p>You can download the file from: <a href=\"https:\/\/www.sciencebase.gov\/catalog\/item\/53f5a87ae4b09d12e0e8547b\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.sciencebase.gov\/catalog\/item\/53f5a87ae4b09d12e0e8547b<\/a><\/p>\n\n\n\n<p>We can convert our GeoTIFF to COG using GDAL.<\/p>\n\n\n\n<p>Place the file on your server and issue below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">gdal_translate FAA_UTM18N_NAD83.tif FAA_COG.tif -of COG -co BLOCKSIZE=256 -co BIGTIFF=IF_SAFER -co COMPRESS=LZW -co PREDICTOR=YES<\/pre>\n\n\n\n<p>Our output should look something like below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Input file size is 1491, 1387\n0...10...20...30...40...50...60...70...80...90...100 - done.<\/pre>\n\n\n\n<p>Let&#8217;s take a look at the GDAL command we used.  You can adjust these, of course, for your own files.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>FAA_UTM18N_NAD83.tif is our input file<\/li>\n\n\n\n<li>FAA_COG.tif is our output file<\/li>\n\n\n\n<li>&#8216;-of COG&#8217; our output file type is COG<\/li>\n\n\n\n<li>Our Creation Options, &#8216;-co&#8217; are:\n<ul class=\"wp-block-list\">\n<li>BLOCKSIZE=256 &#8211; default is 512.  <\/li>\n\n\n\n<li>BIGTIFF=IF_SAFER &#8211; this will create a BIGTIFF is the output file exceeds 4 GB<\/li>\n\n\n\n<li>COMPRESS=LZW &#8211; this is our compression type (default)<\/li>\n\n\n\n<li>PREDICTOR=YES &#8211; set to use to create BIGTIFF if required<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>If we wish to, we can now validate the COG we have created using COG Validator (<a href=\"https:\/\/github.com\/rouault\/cog_validator\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/rouault\/cog_validator<\/a>)<\/p>\n\n\n\n<p>It&#8217;s a good idea to validate your COG as GeoServer can be very picky about COGs.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">wget https:\/\/raw.githubusercontent.com\/rouault\/cog_validator\/refs\/heads\/master\/validate_cloud_optimized_geotiff.py<\/pre>\n\n\n\n<p>Our output should look like below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">FAA_COG.tif is a valid cloud optimized GeoTIFF\n\nThe size of all IFD headers is 1532 bytes\n<\/pre>\n\n\n\n<p>You can find the full GDAL COG reference at:  <a href=\"https:\/\/gdal.org\/en\/latest\/drivers\/raster\/cog.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/gdal.org\/en\/latest\/drivers\/raster\/cog.html<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post will cover converting a GeoTIFF to Cloud Optimized GeoTIFF (COG) For our example, let&#8217;s use the GeoTIFF file FAA_UTM18N_NAD83.tif from the U.S. Geological Survey. You can download the file from: https:\/\/www.sciencebase.gov\/catalog\/item\/53f5a87ae4b09d12e0e8547b We can convert our GeoTIFF to COG using GDAL. Place the file on your server and issue below: Our output should look &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.acugis.com\/gis-tutorials\/geoserver\/convert-geotiff-to-cog\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Convert GeoTIFF to COG&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":48,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-345","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.acugis.com\/gis-tutorials\/wp-json\/wp\/v2\/pages\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.acugis.com\/gis-tutorials\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.acugis.com\/gis-tutorials\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.acugis.com\/gis-tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.acugis.com\/gis-tutorials\/wp-json\/wp\/v2\/comments?post=345"}],"version-history":[{"count":1,"href":"https:\/\/www.acugis.com\/gis-tutorials\/wp-json\/wp\/v2\/pages\/345\/revisions"}],"predecessor-version":[{"id":346,"href":"https:\/\/www.acugis.com\/gis-tutorials\/wp-json\/wp\/v2\/pages\/345\/revisions\/346"}],"up":[{"embeddable":true,"href":"https:\/\/www.acugis.com\/gis-tutorials\/wp-json\/wp\/v2\/pages\/48"}],"wp:attachment":[{"href":"https:\/\/www.acugis.com\/gis-tutorials\/wp-json\/wp\/v2\/media?parent=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}