From a4c391cf6d7469f30e9d9e2bf8f4bc9b3712787a Mon Sep 17 00:00:00 2001 From: banesullivan Date: Tue, 13 Apr 2021 11:35:46 -0600 Subject: [PATCH 1/5] Add option to turn off BIGTIFF --- utilities/converter/large_image_converter/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utilities/converter/large_image_converter/__init__.py b/utilities/converter/large_image_converter/__init__.py index 1d2d61620..50a2b8e3a 100644 --- a/utilities/converter/large_image_converter/__init__.py +++ b/utilities/converter/large_image_converter/__init__.py @@ -94,6 +94,7 @@ def _generate_geotiff(inputPath, outputPath, **kwargs): :param level: compression level for zstd, 1-22 (default is 10). :param predictor: one of 'none', 'horizontal', 'float', or 'yes' used for lzw and deflate. + :param bigTiff: either 'yes' or 'no' """ from osgeo import gdal from osgeo import gdalconst @@ -103,6 +104,7 @@ def _generate_geotiff(inputPath, outputPath, **kwargs): 'compression': 'lzw', 'quality': 90, 'predictor': 'yes', + 'bigTiff': 'yes', } predictor = { 'none': 'NO', @@ -111,7 +113,8 @@ def _generate_geotiff(inputPath, outputPath, **kwargs): 'yes': 'YES', } options.update({k: v for k, v in kwargs.items() if v not in (None, '')}) - cmdopt = ['-of', 'COG', '-co', 'BIGTIFF=YES'] + cmdopt = ['-of', 'COG'] + cmdopt += ['-co', 'BIGTIFF=%d' % predictor[options['bigTiff']]] cmdopt += ['-co', 'BLOCKSIZE=%d' % options['tileSize']] cmdopt += ['-co', 'COMPRESS=%s' % options['compression'].upper()] cmdopt += ['-co', 'QUALITY=%s' % options['quality']] From 52311837fa4aafd9c56d891de570876eceb880b4 Mon Sep 17 00:00:00 2001 From: banesullivan Date: Tue, 13 Apr 2021 11:40:31 -0600 Subject: [PATCH 2/5] Use dedicated yes/no dict for bigtiff options --- utilities/converter/large_image_converter/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/utilities/converter/large_image_converter/__init__.py b/utilities/converter/large_image_converter/__init__.py index 50a2b8e3a..d00ed9fee 100644 --- a/utilities/converter/large_image_converter/__init__.py +++ b/utilities/converter/large_image_converter/__init__.py @@ -106,15 +106,18 @@ def _generate_geotiff(inputPath, outputPath, **kwargs): 'predictor': 'yes', 'bigTiff': 'yes', } - predictor = { + yes_no = { 'none': 'NO', - 'horizontal': 'STANDARD', - 'float': 'FLOATING_POINT', + 'no': 'NO', 'yes': 'YES', } + predictor = { + 'horizontal': 'STANDARD', + 'float': 'FLOATING_POINT', + }.update(yes_no) options.update({k: v for k, v in kwargs.items() if v not in (None, '')}) cmdopt = ['-of', 'COG'] - cmdopt += ['-co', 'BIGTIFF=%d' % predictor[options['bigTiff']]] + cmdopt += ['-co', 'BIGTIFF=%d' % predictor[yes_no['bigTiff']]] cmdopt += ['-co', 'BLOCKSIZE=%d' % options['tileSize']] cmdopt += ['-co', 'COMPRESS=%s' % options['compression'].upper()] cmdopt += ['-co', 'QUALITY=%s' % options['quality']] From 1d2d2aaaee43084cd5a39c1ff152979701e1099b Mon Sep 17 00:00:00 2001 From: banesullivan Date: Tue, 13 Apr 2021 17:20:37 -0600 Subject: [PATCH 3/5] Fix typo --- utilities/converter/large_image_converter/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/converter/large_image_converter/__init__.py b/utilities/converter/large_image_converter/__init__.py index d00ed9fee..c82975a12 100644 --- a/utilities/converter/large_image_converter/__init__.py +++ b/utilities/converter/large_image_converter/__init__.py @@ -117,7 +117,7 @@ def _generate_geotiff(inputPath, outputPath, **kwargs): }.update(yes_no) options.update({k: v for k, v in kwargs.items() if v not in (None, '')}) cmdopt = ['-of', 'COG'] - cmdopt += ['-co', 'BIGTIFF=%d' % predictor[yes_no['bigTiff']]] + cmdopt += ['-co', 'BIGTIFF=%d' % options[yes_no['bigTiff']]] cmdopt += ['-co', 'BLOCKSIZE=%d' % options['tileSize']] cmdopt += ['-co', 'COMPRESS=%s' % options['compression'].upper()] cmdopt += ['-co', 'QUALITY=%s' % options['quality']] From d9d80fbe5f5fcf7b3ba490fb8809bf51a97cb7ae Mon Sep 17 00:00:00 2001 From: banesullivan Date: Tue, 13 Apr 2021 17:23:26 -0600 Subject: [PATCH 4/5] Add more BIGTIFF options --- utilities/converter/large_image_converter/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/utilities/converter/large_image_converter/__init__.py b/utilities/converter/large_image_converter/__init__.py index c82975a12..1acd926ca 100644 --- a/utilities/converter/large_image_converter/__init__.py +++ b/utilities/converter/large_image_converter/__init__.py @@ -94,7 +94,7 @@ def _generate_geotiff(inputPath, outputPath, **kwargs): :param level: compression level for zstd, 1-22 (default is 10). :param predictor: one of 'none', 'horizontal', 'float', or 'yes' used for lzw and deflate. - :param bigTiff: either 'yes' or 'no' + :param bigTiff: either 'yes', 'no', 'needed', or 'safer'. Default 'safer'. """ from osgeo import gdal from osgeo import gdalconst @@ -104,7 +104,7 @@ def _generate_geotiff(inputPath, outputPath, **kwargs): 'compression': 'lzw', 'quality': 90, 'predictor': 'yes', - 'bigTiff': 'yes', + 'bigTiff': 'safer', } yes_no = { 'none': 'NO', @@ -115,9 +115,13 @@ def _generate_geotiff(inputPath, outputPath, **kwargs): 'horizontal': 'STANDARD', 'float': 'FLOATING_POINT', }.update(yes_no) + big_tiff = { + 'needed': 'IF_NEEDED', + 'safer': 'IF_SAFER', + }.update(yes_no) options.update({k: v for k, v in kwargs.items() if v not in (None, '')}) cmdopt = ['-of', 'COG'] - cmdopt += ['-co', 'BIGTIFF=%d' % options[yes_no['bigTiff']]] + cmdopt += ['-co', 'BIGTIFF=%d' % options[big_tiff['bigTiff']]] cmdopt += ['-co', 'BLOCKSIZE=%d' % options['tileSize']] cmdopt += ['-co', 'COMPRESS=%s' % options['compression'].upper()] cmdopt += ['-co', 'QUALITY=%s' % options['quality']] From 7a95177cac55c69b2e72de2e2a114823a680f0d1 Mon Sep 17 00:00:00 2001 From: banesullivan Date: Tue, 13 Apr 2021 17:24:27 -0600 Subject: [PATCH 5/5] Fix typo --- utilities/converter/large_image_converter/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/converter/large_image_converter/__init__.py b/utilities/converter/large_image_converter/__init__.py index 1acd926ca..e0c0b9cc2 100644 --- a/utilities/converter/large_image_converter/__init__.py +++ b/utilities/converter/large_image_converter/__init__.py @@ -121,7 +121,7 @@ def _generate_geotiff(inputPath, outputPath, **kwargs): }.update(yes_no) options.update({k: v for k, v in kwargs.items() if v not in (None, '')}) cmdopt = ['-of', 'COG'] - cmdopt += ['-co', 'BIGTIFF=%d' % options[big_tiff['bigTiff']]] + cmdopt += ['-co', 'BIGTIFF=%d' % big_tiff[options['bigTiff']]] cmdopt += ['-co', 'BLOCKSIZE=%d' % options['tileSize']] cmdopt += ['-co', 'COMPRESS=%s' % options['compression'].upper()] cmdopt += ['-co', 'QUALITY=%s' % options['quality']]