From ca9730df45384b3c5de489d45dd8101fff4875b9 Mon Sep 17 00:00:00 2001
From: "Daniel.Frisinghelli" <daniel.frisinghelli@eurac.edu>
Date: Mon, 1 Feb 2021 17:24:25 +0100
Subject: [PATCH] Added a utility function to mosaic rasters.

---
 pysegcnn/core/utils.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/pysegcnn/core/utils.py b/pysegcnn/core/utils.py
index 570aeef..1b62a1c 100644
--- a/pysegcnn/core/utils.py
+++ b/pysegcnn/core/utils.py
@@ -2451,3 +2451,18 @@ def gdb2shp(src_ds, feature=''):
     # call the osgeo ogr2ogr system utility
     subprocess.run('ogr2ogr -f "ESRI Shapefile" {} {} {}'.format(
         src_ds, src_ds.parent, feature))
+
+
+def merge_tifs(trg_ds, tifs):
+    """Mosaic a set of images.
+
+    Parameters
+    ----------
+    trg_ds : `str` or :py:class:`pathlib.Path`
+        Path to the output GeoTiff file.
+    tifs : `list` [`str` or :py:class:`pathlib.Path`]
+        List of paths to the GeoTiffs to mosaic.
+
+    """
+    LOGGER.info('Creating mosaic: {}'.format(trg_ds))
+    gdal.Warp(str(trg_ds), [str(tif) for tif in tifs])
-- 
GitLab