Closed miguelif92 closed 3 years ago
Unlike mean aspect, being a circular variable, mean slope is fairly easy. Procedurally, just calculate slope (in percent, not degrees) and then use a focal mean or median within the desired window size. Both of these steps are readily available in QGIS. 1) Raster > Analysis > slope 2) for focal functions there are options in Processing Toolbox > GRASS > r.neighbors or Processing Toolbox > SAGA > Raster filter or, if the LecoS plugin is installed Processing Toolbox > LecoS > Landscape Modifications > Neighborhood Analysis (Moving Window).
Best, Jeff
Jeffrey S. Evans, Ph.D., | Senior Landscape Ecologist & Biometrician The Nature Conservancy | Protected Lands Science Visiting Professor | University of Wyoming | Zoology & Physiology Laramie, WY | @.**@.> | (970) 672-6766<tel:(970)%20672-6766>
From: Miguel Salamanca @.> Sent: Tuesday, August 10, 2021 2:03 PM To: jeffreyevans/GradientMetrics @.> Cc: Subscribed @.***> Subject: [jeffreyevans/GradientMetrics] Mean Slope calculus in QGIS (#8)
Hi dear Mr. Evans, hope that everything is getting well.
I was trying to calculate mean Slope in QGIS because I want to compare and validate in-situ the slope values using this index but I don't know clearly how to adapt this method using PyQGIS or R-Studio. How can I calculate mean slope in QGIS using this tool by using a DEM as an input and changing the window size?
I will thank you in advance for your help.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/jeffreyevans/GradientMetrics/issues/8, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLKH75TNWL6XXWPKIQILU3T4GAYDANCNFSM5B42AITA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.
I would note that it is quite easy to do this in R as well, you just have to take the extra step of converting degrees to percent (mean angle is somewhat nonsensical). We can use the terra and spatialEco package(s) and, in fact, in the next release of spatialEco, I will add the mean slope function. There are already many of the metrics, from the ArcGIS Gradient toolbox, available in the spatialEco package.
library(spatialEco) library(terra)
data(elev) elev <- rast(elev)
slp.deg <- terrain(elev, v="slope", neighbors=8, unit="degrees")
deg2pct <- function(x) { tan(x pi/180) 100 } slp.pct <- app(slp.deg, deg2pct) slp.pct [slp.pct > 100] <- 100
mean.slp <- focal(slp.pct, matrix(1, 5, 5), mean) plot(c(slp.pct, mean.slp))
Best, Jeff
Jeffrey S. Evans, Ph.D., | Senior Landscape Ecologist & Biometrician The Nature Conservancy | Protected Lands Science Visiting Professor | University of Wyoming | Zoology & Physiology Laramie, WY | @.**@.> | (970) 672-6766<tel:(970)%20672-6766>
From: Miguel Salamanca @.> Sent: Tuesday, August 10, 2021 2:03 PM To: jeffreyevans/GradientMetrics @.> Cc: Subscribed @.***> Subject: [jeffreyevans/GradientMetrics] Mean Slope calculus in QGIS (#8)
Hi dear Mr. Evans, hope that everything is getting well.
I was trying to calculate mean Slope in QGIS because I want to compare and validate in-situ the slope values using this index but I don't know clearly how to adapt this method using PyQGIS or R-Studio. How can I calculate mean slope in QGIS using this tool by using a DEM as an input and changing the window size?
I will thank you in advance for your help.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/jeffreyevans/GradientMetrics/issues/8, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLKH75TNWL6XXWPKIQILU3T4GAYDANCNFSM5B42AITA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.
Dear Mr. Evans,
According to the suggestions that you wrote previously, I tried and tested the different options and results were similar with the ones obtained by using your toolbox on ArcGIS. Thanks a lot for the information provided by this media and the code given for R. I might use it soon for terrain analysis.
Thanks a lot for your help.
Have a great time!
Hi dear Mr. Evans, hope that everything is getting well.
I was trying to calculate mean Slope in QGIS because I want to compare and validate in-situ the slope values using this index but I don't know clearly how to adapt this method using PyQGIS or R-Studio. How can I calculate mean slope in QGIS using this tool by using a DEM as an input and changing the window size?
I will thank you in advance for your help.