# How is slope calculated

Qiao
Global Mapper UserPosts:

**74**Trusted User
Hi Mike,

I am wondering how the slope is calculated when using the slope option in exporting to a Float/Grid. Given a pixel, is the slope calculated using the elevation difference to one of its 8 neighborhood pixelss. I assum you take the maximal slope value among this 8 possible values. How about the pixels on the boundaries (the first/last col/row)? Do you still use similar approach but with a smaller neighborhood (for example, at corners, only four possible elevation differences)? This slope map does not involve in any resampling (i.e., not matter what you choose in your resampling options for the selected layer), right?

I am thinking of two potential issues. 1) How to avoid the boundary issues if our elevation grids are tiled with one pixel overlapping? 2) What would be the best option to generate a smoother slope map (smoothing the elevation grid first? increasing the distance from 1 pixel to n pixels in slope calculation? smoothing slope grid?).

Thanks in advance,

Qiao

I am wondering how the slope is calculated when using the slope option in exporting to a Float/Grid. Given a pixel, is the slope calculated using the elevation difference to one of its 8 neighborhood pixelss. I assum you take the maximal slope value among this 8 possible values. How about the pixels on the boundaries (the first/last col/row)? Do you still use similar approach but with a smaller neighborhood (for example, at corners, only four possible elevation differences)? This slope map does not involve in any resampling (i.e., not matter what you choose in your resampling options for the selected layer), right?

I am thinking of two potential issues. 1) How to avoid the boundary issues if our elevation grids are tiled with one pixel overlapping? 2) What would be the best option to generate a smoother slope map (smoothing the elevation grid first? increasing the distance from 1 pixel to n pixels in slope calculation? smoothing slope grid?).

Thanks in advance,

Qiao

## Comments

17,238The slope is calculated by computing the slope from the sample to the left of a location to the sample to the right of the location, then the slope from the sample below to the sample above, then doing the square root of the sum of the squares of those 2 slope values to get a single slope value.

None of the box average/min/max resamplers are applied to slopes, but bilinear interpolation should be. If you are chopping up on export so long as all of the data is loaded and available when you do the export the slopes should be correct, assuming you are starting with just a single grid layer and don't already have boundaries where the slope calculations don't have everything to work with.

Thanks,

Mike

Global Mapper Guru

gmsupport@bluemarblegeo.com

Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation