6

This question already has an answer here:

I'm attempting a simple slope analysis in QGIS2 using the plugin at Raster -> Terrain Analysis -> Slope. The slope output layer has a very strange histogram, basically spikes at 0 and at 89.9098 with one big valley in the middle:

enter image description here

Here's the initial DEM:

enter image description here

And the resulting slope layer (note that Contrast Enhancement is already at 'stretch to minmax'):

enter image description here

The place I got the DEM is the NED. I tried the gridfloat format, and the arcgrid format, and the IMG format. I downloaded from nationalmap and also from atlas.ca.gov - all seem to have the same resulting histogram.

The procedure I used to make the slope layer was Raster -> Terrain Analysis -> Slope, GeoTIFF, Z factor = 1.0 (what does that do anyway?)

Seems like simple pilot error; however: I found this tutorial online (for QGIS 1.something) that comes with a sample DEM, and it worked just fine using the same procedure. So, it's not a fundamental QGIS2 bug.

So, it must be slightly more complex pilot error: there must be a conversion step or something I'm missing?

marked as duplicate by Andre Silva, whyzar, xunilk, aldo_tapia, BERA Jan 3 '18 at 12:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

6

Interesting. I just did the same thing, with the same results. It turns out that QGIS assumes that the vertical units are the same as the CRS units.

My test image was unprojected Lat/Lon and I'm assuming yours is too? I reprojected the image to UTM (so units would be meters) and the slope calculation worked just fine.

To try this yourself, right-click on your DEM, go to Save As, and under CRS, set it to a meters-based projection (UTM should work fine.) Then try the slope calculation on your newly saved DEM.

EDIT: This will obviously only work if your data is actually in meters. If it's feet, choose a projection with feet as units.

  • That does the trick. The DEM I got was in NAD83 (EPSG:4269) so I saved as NAD83 UTM zone 10N then did the slope analysis and it looks good - min is 0, max is about 41, the histo looks realistic, so, it's believable but I will fact-check it tomorrow. Seems strange that you actually need to reproject it to just change the Z scale factor... but, I tried the original NAD83 data with Z factor 0.3048 (meters per foot) and also Z factor 3.28084 (feet per meter) - both gave the same spikes-at-rails histogram. ...? Most likely is that I just don't fully understand the concept of projections here. – Tom Grundy Dec 8 '13 at 5:46
  • 1
    another odd thing is that saving the DEM as NAD 83 UTM zone 10N changed the min and max values a bit. Orig min/max = 715.234/2372.85; new min/max = 703.737/2378.32. I guess this is just unavoidable artifact of the reprojection algorithm? – Tom Grundy Dec 8 '13 at 5:53
  • found this when googling 'qgis slope z factor': From Version 1.8 on, you can set the parameter 'z-scale' if your x-/y- units are different than the z-unit. If e.g. x-/y- is degrees and z meters, you may set z-Factor 111120. So - that avoids the need to reproject. Still looking to track down documentation on z-factor. – Tom Grundy Dec 8 '13 at 6:00
  • 1
    Seems like the suggestion to use 111120 is not really valid since there's no way to use one number to convert degrees to meters, which is why you have to project it first to a system that does use meters. It would be nice if the slope tool told you this right off the bat to save some effort and error. – Tom Grundy Dec 11 '13 at 1:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.