From 12dac7cd202c89883758a5b871632fc747cb1857 Mon Sep 17 00:00:00 2001 From: Stephen Vincent Mather Date: Wed, 29 Jun 2022 15:38:27 -0400 Subject: [PATCH] fix all the big(tiff) problems --- contrib/orthorectify/orthorectify.py | 2 +- contrib/visveg/vegind.py | 2 +- opendm/cutline.py | 2 +- opendm/dem/commands.py | 2 +- opendm/dem/merge.py | 2 +- opendm/orthophoto.py | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/orthorectify/orthorectify.py b/contrib/orthorectify/orthorectify.py index f09a4483..548fc1e0 100755 --- a/contrib/orthorectify/orthorectify.py +++ b/contrib/orthorectify/orthorectify.py @@ -381,7 +381,7 @@ with rasterio.open(dem_path) as dem_raster: if not outfile.endswith(".tif"): outfile = outfile + ".tif" - with rasterio.open(outfile, 'w', **profile) as wout: + with rasterio.open(outfile, 'w', BIGTIFF="IF_SAFER", **profile) as wout: for b in range(num_bands): wout.write(imgout[b], b + 1) if with_alpha: diff --git a/contrib/visveg/vegind.py b/contrib/visveg/vegind.py index 62554657..42dcb62d 100644 --- a/contrib/visveg/vegind.py +++ b/contrib/visveg/vegind.py @@ -88,7 +88,7 @@ try: elif typ == 'tgi': indeks = calcTgi(red, green, blue) - with rasterio.open(outFileName, 'w', **profile) as dst: + with rasterio.open(outFileName, 'w', BIGTIFF="IF_SAFER", **profile) as dst: dst.write(indeks.astype(rasterio.float32), 1) except rasterio.errors.RasterioIOError: print bcolors.FAIL + 'Orthophoto file not found or access denied' + bcolors.ENDC diff --git a/opendm/cutline.py b/opendm/cutline.py index 6c6153ba..e3f8bf8b 100644 --- a/opendm/cutline.py +++ b/opendm/cutline.py @@ -35,7 +35,7 @@ def write_raster(data, file): 'crs': None } - with rasterio.open(file, 'w', **profile) as wout: + with rasterio.open(file, 'w', BIGTIFF="IF_SAFER", **profile) as wout: wout.write(data, 1) def compute_cutline(orthophoto_file, crop_area_file, destination, max_concurrency=1, scale=1): diff --git a/opendm/dem/commands.py b/opendm/dem/commands.py index a1d09bf0..1740c3cd 100755 --- a/opendm/dem/commands.py +++ b/opendm/dem/commands.py @@ -328,7 +328,7 @@ def median_smoothing(geotiff_path, output_path, smoothing_iterations=1): arr[nodata_locs] = nodata # write output - with rasterio.open(output_path, 'w', **img.profile) as imgout: + with rasterio.open(output_path, 'w', BIGTIFF="IF_SAFER", **img.profile) as imgout: imgout.write(arr, 1) log.ODM_INFO('Completed smoothing to create %s in %s' % (output_path, datetime.now() - start)) diff --git a/opendm/dem/merge.py b/opendm/dem/merge.py index fdeef93a..6647e505 100644 --- a/opendm/dem/merge.py +++ b/opendm/dem/merge.py @@ -92,7 +92,7 @@ def euclidean_merge_dems(input_dems, output_dem, creation_options={}, euclidean_ profile.update(creation_options) # create destination file - with rasterio.open(output_dem, "w", **profile) as dstrast: + with rasterio.open(output_dem, "w", BIGTIFF="IF_SAFER", **profile) as dstrast: for idx, dst_window in dstrast.block_windows(): diff --git a/opendm/orthophoto.py b/opendm/orthophoto.py index 72f99954..f99197c0 100644 --- a/opendm/orthophoto.py +++ b/opendm/orthophoto.py @@ -129,7 +129,7 @@ def compute_mask_raster(input_raster, vector_mask, output_raster, blend_distance else: log.ODM_WARNING("%s does not have an alpha band, cannot blend cutline!" % input_raster) - with rasterio.open(output_raster, 'w', **rast.profile) as dst: + with rasterio.open(output_raster, 'w', BIGTIFF="IF_SAFER", **rast.profile) as dst: dst.colorinterp = rast.colorinterp dst.write(out_image) @@ -154,7 +154,7 @@ def feather_raster(input_raster, output_raster, blend_distance=20): else: log.ODM_WARNING("%s does not have an alpha band, cannot feather raster!" % input_raster) - with rasterio.open(output_raster, 'w', **rast.profile) as dst: + with rasterio.open(output_raster, 'w', BIGTIFF="IF_SAFER", **rast.profile) as dst: dst.colorinterp = rast.colorinterp dst.write(out_image) @@ -230,7 +230,7 @@ def merge(input_ortho_and_ortho_cuts, output_orthophoto, orthophoto_vars={}): profile.update() # create destination file - with rasterio.open(output_orthophoto, "w", **profile) as dstrast: + with rasterio.open(output_orthophoto, "w", BIGTIFF="IF_SAFER", **profile) as dstrast: dstrast.colorinterp = colorinterp for idx, dst_window in dstrast.block_windows(): left, bottom, right, top = dstrast.window_bounds(dst_window)