PCI Geomatics Help Center

How can we help you today?

Multiview DSM Merging in Python

PCI Geomatics -


DSMMERGE is a great new function that allows users to generate significantly better digital surface models (DSM) by merging a set of geocoded DSMs from a stereo airphoto or satellite project into a single multiview DSM. The final DSMMERGE result is typically of higher quality compared to a single DSM since each geocoded DSM has a different viewing geometry. Also occlusions in one DSM can be filled in from a different DSM.

To achieve the best possible result when working with aerial images, we recommend an overlap of 80/60 as well as good aerotriangulation between images.

More information on the DSMMERGE algorithm and workflow are found in the Geomatica Help documentation. Tutorials for working in Python are found on our Developer Zone.

Other DSM merging methods are available, but are used in slightly different circumstances. SGMMERGE is intended to merge Forward/Nadir (F/N) and Backward/Nadir (B/N) pairs of images in the nadir epipolar space followed by geocoding via GEOCODEDEM.

***In Geomatica Banff, DSMMERGE has been added into the OrthoEngine DEM extraction workflow, available as an output option when SGM (Semi-global matching) is selected for DEM Extraction Options. Here, Merge can also attempt to straighten building edges, if applicable. That is, with Merge selected, you can select the Clean up building edges with filter size check box, and then in the box to the right, type or select the size of the filter to use. The recommended value is 13.


The following example shows how to run the DSMMERGE algorithm in Python. This script requires a set of overlapping geocoded DSM’s created from an airphoto project. All files must have the same projection and resolution. In each file, band 1 contains the DSM, bands 2,3,4 contain RGB imagery and band 5 contains the score channel. Since the DSMs produced do not perfectly align vertically due to small errors in the exterior orientation a larger blend width of 100 is used (instead of the default of 48) and the error tolerance is set to 10 (instead of the default of 4).

# Import the dsmmerge algorithm from the Geomatica python library
from pci.dsmmerge import dsmmerge

# List of geocoded DSM files, typically produced by GEOCODEDEM as part of a DSM extraction process.
# All files must have the same projection, resolution and band sequence.
mfile = r"I:\Tutorials\DSMMERGE\*.pix"

# Specifies the input band (channel) that contains the digital elevation model to be used.
dbec = [1]

# Input score channel. This information is very important as the software uses the input score channel for elevation selection.
# Typcially this is a mask that shows valid DSM values, failed DSM locations, and No Data pixels.
dbscore = [5]

# Optionally specifies the imagery channels that should be merged to create a rough image overlay to the DSM.
# These are assumed to be bands already in each geocoded DSM file.
dbimage = [2,3,4]

# The name of the output file. A file with the same name must not exist in the output folder.
filo = r"I:\Tutorials\DSMMERGE\merged_dsm.pix"

# Edgefix specifies the size of the filter used to clean up building and tree edges.
# If unspecified then a value of 13 is used. Specifying a value of 0 switches off this option.
edgefix = [9]

# The level of filtering to apply to the generated DSM.
demfilt = "medium"

# Demopts specifies special processing options. The options include speckle, blend and maxerror.
demopts = "blend=100  maxerror=10"

dsmmerge(mfile, dbec, dbscore, dbimage, filo, edgefix, demfilt, demopts)


The results of the final merged DSM are seen below. The images show a zoomed in area of a number of buildings, trees and roads. The first image shows the original DSM while the second image shows the merged DSM. You will notice that the final merged DSM produced a much clearer, less blurry result.

Looking at the areas highlighted by red boxes, you can see the building footprints are a lot straighter and represent real building shapes. All of the building edges, trees and roads have been taken in and now represent true ground locations.  

Looking at the third image you can see that the edgest of the buildings in the merged DSM match up perfectly with the buildings in the true color image.

Image 1 – Original DSM image

Image 2 – Merged DSM using DSMMERGE

Image 3 – Comparing the merged DSM to the true colored imagery. Notice the edges of the buildings and roads match up perfectly.


The benefit of running DSMMERGE on your DSM files is that the resulting image is a higher quality result compared to a single DSM. The output will not require as much manual editing afterwards as occlusions are filled in by overlapping DSMs. The final merged DSM can then be used as an input for a True Orthorectification workflow.

Have more questions? Submit a request


Powered by Zendesk