r - How to select specific pixels from raster (slope >=certain value) -


i hope didn´t overlook similar problem somewhere else on side, couldn´t answer on problem yet...

i have dem resolution of 10x10m. need find pixels have slope >35° , find out exposition. (after (?) this, need link somehow grid program of 100x100m , further work on them). how can best?

what 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 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. returns matrix , coordinates gone (which need later link pixels dem pixels of .asc file). well, don´t know how solve task, unluckily r-beginner... thank help!

you can obtain raster pixels on 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 raster file valid values in pixels slope value on 35. can use other grid further analysis.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -