class xdem.coreg.ICP(max_iterations=100, tolerance=0.05, rejection_scale=2.5, num_levels=6, subsample=500000.0)[source]#

Iterative closest point registration, based on Besl and McKay (1992), https://doi.org/10.1117/12.57955.

Estimates a rigid transform (rotation + translation) between two elevation datasets.

The transform is stored in the self.meta key “matrix”, with rotation centered on the coordinates in the key “centroid”. The translation parameters are also stored individually in the keys “shift_x”, “shift_y” and “shift_z” (in georeferenced units for horizontal shifts, and unit of the elevation dataset inputs for the vertical shift).

Requires ‘opencv’. See opencv doc for more info: https://docs.opencv.org/master/dc/d9b/classcv_1_1ppf__match__3d_1_1ICP.html

__init__(max_iterations=100, tolerance=0.05, rejection_scale=2.5, num_levels=6, subsample=500000.0)[source]#

Instantiate an ICP coregistration object.

  • max_iterations (int) – The maximum allowed iterations before stopping.

  • tolerance (float) – The residual change threshold after which to stop the iterations.

  • rejection_scale (float) – The threshold (std * rejection_scale) to consider points as outliers.

  • num_levels (int) – Number of octree levels to consider. A higher number is faster but may be more inaccurate.

  • subsample (float | int) – Subsample the input for speed-up. <1 is parsed as a fraction. >1 is a pixel count.


__init__([max_iterations, tolerance, ...])

Instantiate an ICP coregistration object.

apply(elev[, bias_vars, resample, ...])

Apply the estimated transform to a DEM.


Get the centroid of the coregistration, if defined.


Return an identical copy of the class.

error(reference_elev, to_be_aligned_elev[, ...])

Calculate the error of a coregistration approach.

fit(reference_elev, to_be_aligned_elev[, ...])

Estimate the coregistration transform on the given DEMs.

fit_and_apply(reference_elev, to_be_aligned_elev)

Estimate and apply the coregistration to a pair of elevation data.


Instantiate a generic Coreg class from a transformation matrix.

from_translation([x_off, y_off, z_off])

Instantiate a generic Coreg class from a X/Y/Z translation.

residuals(reference_elev, to_be_aligned_elev)

Calculate the residual offsets (the difference) between two DEMs after applying the transformation.


Convert the transform to a 4x4 transformation matrix.



Check if the transform be explained by a 3D affine transform.


Metadata dictionary of the coregistration.