Skip to content

Commit

Permalink
Improved docstring for apply_matrix()
Browse files Browse the repository at this point in the history
  • Loading branch information
erikmannerfelt committed Apr 21, 2021
1 parent fbdb6ef commit 0c9d568
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion xdem/coreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,17 @@ def apply_matrix(dem: np.ndarray, transform: rio.transform.Affine, matrix: np.nd
centroid: Optional[tuple[float, float, float]] = None,
resampling: Union[int, str] = "cubic") -> np.ndarray:
"""
Apply a transformation matrix to a DEM.
Apply a 3D transformation matrix to a 2.5D DEM.
The transformation is applied as a value correction using linear deramping, and 2D image warping.
1. Convert the DEM into a point cloud (not for gridding; for estimating the DEM shifts).
2. Transform the point cloud in 3D using the 4x4 matrix.
3. Measure the difference in elevation between the original and transformed points.
4. Estimate a linear deramp from the elevation difference, and apply the correction to the DEM values.
5. Convert the horizontal coordinates of the transformed points to pixel index coordinates.
6. Apply the pixel-wise displacement in 2D using the new pixel coordinates.
7. Apply the same displacement to a nodata-mask to exclude previous and/or new nans.
:param dem: The DEM to transform.
:param transform: The Affine transform object (georeferencing) of the DEM.
Expand Down

0 comments on commit 0c9d568

Please sign in to comment.