diff --git a/opendm/cutline.py b/opendm/cutline.py index 090d6f19..611a06a4 100644 --- a/opendm/cutline.py +++ b/opendm/cutline.py @@ -4,13 +4,17 @@ from opendm import log from opendm import io from opendm import concurrency from opendm import get_image_size +from opendm import system import math -def compute_cutline(orthophoto_file, crop_area_file, destination, max_concurrency=1): +def compute_cutline(orthophoto_file, crop_area_file, destination, max_concurrency=1, tmpdir=None): if io.file_exists(orthophoto_file) and io.file_exists(crop_area_file): from opendm.grass_engine import grass log.ODM_DEBUG("Computing cutline") + if not io.dir_exists(tmpdir): + system.mkdir_p(tmpdir) + try: ortho_width,ortho_height = get_image_size.get_image_size(orthophoto_file) log.ODM_DEBUG("Orthophoto dimensions are %sx%s" % (ortho_width, ortho_height)) @@ -21,7 +25,7 @@ def compute_cutline(orthophoto_file, crop_area_file, destination, max_concurrenc log.ODM_DEBUG("Number of lines: %s" % number_lines) - gctx = grass.create_context({'auto_cleanup' : False}) + gctx = grass.create_context({'auto_cleanup' : False, 'tmpdir': tmpdir}) gctx.add_param('orthophoto_file', orthophoto_file) gctx.add_param('crop_area_file', crop_area_file) gctx.add_param('number_lines', number_lines) diff --git a/scripts/odm_orthophoto.py b/scripts/odm_orthophoto.py index 9d7a4e07..9c8a9dda 100644 --- a/scripts/odm_orthophoto.py +++ b/scripts/odm_orthophoto.py @@ -115,7 +115,8 @@ class ODMOrthoPhotoStage(types.ODM_Stage): compute_cutline(tree.odm_orthophoto_tif, bounds_file_path, os.path.join(tree.odm_orthophoto, "cutline.gpkg"), - args.max_concurrency) + args.max_concurrency, + tmpdir=os.path.join(tree.odm_orthophoto, "grass_cutline_tmpdir")) if args.crop > 0: Cropper.crop(bounds_file_path, tree.odm_orthophoto_tif, orthophoto_vars)