grdgradient -S says: Name of output grid file with scalar magnitudes of gradient vectors.

Does this mean that output is in radians?

No. Gradient magnitude is in z-data-units/horizontal distance.

Thanks Paul.

So in order to get the degree of slope, I could take `arctan(z-data-units/horizontal distance)` (based on this)?
Are there any gmt-utilities that can do this for me directly, or do I have to use some `grdmath` RPN magic?

So slope only makes sense for DEMs. For other data types there is no āangleā, just things like mGal/km. If you converted to flat Earth scaling (via -fg) then I think the gradients for a DEM will be in meters/km and you would need to scale it by 0.001 to get dimensionless tangents and then inverse tangent to get the angle.

Try this to get a slope grid in degrees.

``````    gmt grdmath \$GRD ATAND = \$SLP
``````

`grdgdal` says it can do it.

-A prog[+m method +c cpt]

Select which GDAL program to run (currently one of info, dem, grid, rasterize, translate or warp). When program is dem then please append +m method (pick one of hillshade, color-relief, slope, TRI, TPI or roughness)

Thank you all for tips and comments. Will test.

• @Esteban82: Paul mentioned to scale by 0.001 to get m/m; you donāt do that in your script, why not?
• @pwessel: The math behind `grdgradient`; is the gradient that is computed the same as the gradient in physics? So (upside down triangle, del, ā)(x,y,z)? Partial derivatives? In deep water hereā¦

Mmm note sure, but I would say that it is not neccerary.

1 Like

Yes, the gradient is the vector i * dz/dx + j * dz/dy where i and j are the unit vectors in the x and y directions. Then the magnitude of this vector is reported by grdgradient and its direction via -S.

1 Like

@Esteban82: Ok, thanks!
@pwessel: Thank you! I should read some calculusā¦