0
votes

I hope I didn´t overlook a similar problem somewhere else on this side, but I couldn´t get an answer on my problem yet...

I have a DEM with a resolution of 10x10m. I need to find all the pixels which have a slope >35° and find out their exposition. (After (?) this, I need to link it somehow with a grid from another program of 100x100m and do further work on them). How can I do this best?

What I did until now:

DEM=raster("DEM_10m.tif")

DEM
class       : RasterLayer 
dimensions  : 2731, 2407, 6573517  (nrow, ncol, ncell)
resolution  : 10, 10  (x, y)
extent      : 57495.5, 81565.5, 202547.5, 229857.5  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=tmerc +lat_0=0 +lon_0=10.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +datum=hermannskogel +units=m +no_defs +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 
names       : DEM_10m 
values      : -32768, 32767  (min, max)

slope_aspect <- terrain(DEM, opt=c("slope", "aspect"), unit="degrees")
slope_aspect$elevation <- DEM
slope_aspect
              x        y        slope       aspect
1       79560.5 229462.5 3.007349e+01 3.273391e+02
2       79570.5 229462.5 2.946020e+01 3.351363e+02
3       79550.5 229452.5 3.025771e+01 3.150000e+02
4       79560.5 229452.5 3.200538e+01 3.231301e+02
5       79570.5 229452.5 2.902189e+01 3.374794e+02
6       79540.5 229442.5 2.391028e+01 3.195739e+02
7       79550.5 229442.5 3.054151e+01 3.063844e+02
8       79560.5 229442.5 2.719728e+01 3.110548e+02

etc.

When I do:

slope_35<-slope_aspect[slope_aspect$slope>=35]
slope_35
slope       aspect elevation
      [1,] 35.14579 7.349564e+01       969
      [2,] 35.13729 1.465922e+02       975
      [3,] 35.94211 4.639718e+01      1063
      [4,] 36.00673 4.081508e+01      1057
      [5,] 36.19906 9.785331e+01       917

etc. it returns a matrix and the coordinates are gone (which I probably need later to link the pixels from the DEM to the pixels of a .asc file). Well, I just don´t really know how to solve this task, unluckily I am an R-beginner... Thank you for your help!

1

1 Answers

0
votes

You can obtain a raster with only the pixels over this threshold:

slope_aspect <- terrain(DEM, opt=c("slope", "aspect"), unit="degrees")

slope_aspect_masked <- mask(x = slope_aspect , mask = slope_aspect[[1]]>35 , maskvalue = 0)

The output will be a raster file with valid values in pixels with slope value over 35. You can use it with other grid for further analysis.