refmod.dtm_helper#
Module Contents#
- refmod.dtm_helper.matlab_gradient(img, h)#
- refmod.dtm_helper.dtm2grad(dtm, resolution=1, normalize=False)#
Computes the gradient of a Digital Terrain Model (DTM).
- Parameters:
dtm (numpy.ndarray) – The input DTM as a 2D numpy array.
resolution (float, optional) – The resolution of the DTM. Defaults to 1.
normalize (bool, optional) – Flag indicating whether to normalize the gradient vectors. Defaults to False.
- Returns:
The gradient vectors of the DTM.
- Return type:
(numpy.ndarray)
Examples
>>> dtm = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> dtm2grad(dtm, resolution=0.5, normalize=True) array([[[-2.82842712, -2.82842712, 1.41421356], [-2.82842712, -2.82842712, 1.41421356], [-2.82842712, -2.82842712, 1.41421356]], [[-2.82842712, -2.82842712, 1.41421356], [-2.82842712, -2.82842712, 1.41421356], [-2.82842712, -2.82842712, 1.41421356]], [[-2.82842712, -2.82842712, 1.41421356], [-2.82842712, -2.82842712, 1.41421356], [-2.82842712, -2.82842712, 1.41421356]]])