diff --git a/opendm/config.py b/opendm/config.py index 7dcd3697..07c2c209 100644 --- a/opendm/config.py +++ b/opendm/config.py @@ -354,6 +354,11 @@ def config(): 'https://www.gdal.org/frmt_gtiff.html for more info. ' '\nDefault: %(default)s') + parser.add_argument('--build-overviews', + action='store_true', + default=False, + help='Build orthophoto overviews using gdaladdo.') + parser.add_argument('--zip-results', action='store_true', default=False, diff --git a/opendm/types.py b/opendm/types.py index 3a411c34..4a5ef05a 100644 --- a/opendm/types.py +++ b/opendm/types.py @@ -421,3 +421,4 @@ class ODM_Tree(object): self.odm_orthophoto_corners = io.join_paths(self.odm_orthophoto, 'odm_orthophoto_corners.txt') self.odm_orthophoto_log = io.join_paths(self.odm_orthophoto, 'odm_orthophoto_log.txt') self.odm_orthophoto_tif_log = io.join_paths(self.odm_orthophoto, 'gdal_translate_log.txt') + self.odm_orthophoto_gdaladdo_log = io.join_paths(self.odm_orthophoto, 'gdaladdo_log.txt') diff --git a/scripts/odm_app.py b/scripts/odm_app.py index 63c5baa2..41ae72ec 100644 --- a/scripts/odm_app.py +++ b/scripts/odm_app.py @@ -77,6 +77,7 @@ class ODMApp(ecto.BlackBox): no_tiled=p.args.orthophoto_no_tiled, compress=p.args.orthophoto_compression, bigtiff=p.args.orthophoto_bigtiff, + build_overviews=p.args.build_overviews, verbose=p.args.verbose) } diff --git a/scripts/odm_orthophoto.py b/scripts/odm_orthophoto.py index e16979f6..60d28eae 100644 --- a/scripts/odm_orthophoto.py +++ b/scripts/odm_orthophoto.py @@ -14,6 +14,7 @@ class ODMOrthoPhotoCell(ecto.Cell): params.declare("no_tiled", 'Do not tile tiff', False) params.declare("compress", 'Compression type', 'DEFLATE') params.declare("bigtiff", 'Make BigTIFF orthophoto', 'IF_SAFER') + params.declare("build_overviews", 'Build overviews', False) params.declare("verbose", 'print additional messages to console', False) def declare_io(self, params, inputs, outputs): @@ -119,6 +120,19 @@ class ODMOrthoPhotoCell(ecto.Cell): '-co NUM_THREADS=ALL_CPUS ' '-a_srs \"EPSG:{epsg}\" ' '{png} {tiff} > {log}'.format(**kwargs)) + + if self.params.build_overviews: + log.ODM_DEBUG("Building Overviews") + kwargs = { + 'orthophoto': tree.odm_orthophoto_tif, + 'log': tree.odm_orthophoto_gdaladdo_log + } + # Run gdaladdo + system.run('gdaladdo -ro -r average ' + '--config BIGTIFF_OVERVIEW IF_SAFER ' + '--config COMPRESS_OVERVIEW JPEG ' + '{orthophoto} 2 4 8 16 > {log}'.format(**kwargs)) + geotiffcreated = True if not geotiffcreated: log.ODM_WARNING('No geo-referenced orthophoto created due '