Mosaicking

This section provides recipes related to Geomatica’s automatic mosaicking functions. Here you will discover concepts for automatic color balancing, cutline generation, tiling from vector polygons, clipping mosaics to irregular polygons and more…

Please note that this section expects that you have already generated the ortho images, which will be included in the mosaic.

Automatic color balancing and cutline generation (With QA preview mosaic)

This recipe calls a single function which performs color balancing, image sorting, normalization and cutline generation. It also creates a .MOS file that can be loaded into Geomatica’s Mosaic Tool for performing quality assurance. More information on editing the mosaic preview in the Mosaic Tool can be found in this tutorial: https://support.pcigeomatics.com/hc/en-us/articles/360015189232-Mosaic-Tool-Automatic-Mosaicking-in-Geomatica-2018

from pci.mosprep import mosprep

orthos = r"C:\test\ShawnPy\Data\Mosaic\orthos"
src_img_file = r"C:\test\ShawnPy\Data\Mosaic\mosaic.mos"

mosprep(mfile=orthos, silfile=src_img_file, sortmthd="NEARESTCENTER", normaliz="ADAPTIVE",
        balspec="BUNDLE", cutmthd="MINSQDIFF")

Generate full resolution mosaic (single image)

This recipe demonstrates how to create a single full resolution mosaic file from multiple input images (usually orthos), using the color balancing coefficients and cutlines automatically computed from the MOSPREP function (see above).

from pci.mosdef import mosdef
from pci.mosrun import mosrun

# Create Mosaic Definition XML file to
src_image_file = r"C:\test\ShawnPy\Data\Mosaic\mosaic.mos"  # Output from mosprep
mosdef_file = r"C:\test\ShawnPy\Data\Mosaic\mosdef.xml"

mosdef(silfile=src_image_file, mdfile=mosdef_file, pxszout=[2], blend=[5])

# Create full resolution mosaic
mos_dir = r"C:\test\ShawnPy\Data\Mosaic\FinalMosaic"
source_map = "yes"

mosrun(silfile=src_image_file, mdfile=mosdef_file, outdir=mos_dir, crsrcmap="YES")

Generate Mosaic tiles (from vector map-sheet) with JPEG compression

This recipe creates a full resolution tiled mosaic with jpeg compression set to 75%. This can be very useful when generating large mosaics.

In this recipe, GeoTIFF tiles (with JPEG compression), defined by vector polygons, are generated. The polygons, which define the tiles, can have overlap. Furthermore, the script automatically names the tiles using an attribute field “Tile Code” found in the vector polygon file.

from pci.mosdef import mosdef
from pci.mosrun import mosrun

# Create Mosaic Definition XML file to
src_image_file = r"C:\Mosaic\mosaic.mos"
mosdef_file = r"C:\Mosaic\mosaic_def.xml"
tile_specs = r"VECTOR, C:\tiles.pix, Tile_Code" #tiling parameters

mosdef(silfile=src_image_file, mdfile=mosdef_file, tispec=tile_specs, pxszout=[2], blend=[5],
       ftype="TIF", foptions="JPEG75")

# Create full resolution mosaic
mos_dir = r"C:\Mosaic\Tiles"

mosrun(silfile=src_image_file, mdfile=mosdef_file, outdir=mos_dir, crsrcmap="YES", resample="NEAR")