# [R-sig-Geo] calculate "regional" slope

chris english englishchristophera at gmail.com
Fri Feb 19 12:09:05 CET 2016

```Dominik,

r <- raster(nrows=22, ncols=20, xmn=-58, xmx=-48, ymn=-33, ymx=-22)
vals <- sample.int(1e3,440)
r[ ] <- vals
#raster::terrain
terr_r <- terrain(r, opt='slope', unit='degrees', neighbors=8)
Ah, but it appears you want up sampling to 1.5 degrees rather than 0.5 deg.
so maybe spatial.tools::projectRaster_rigorous then raster:terrain.

I'm inclined to end that last so maybe with a question mark. Sorry for an
essentially inconclusive response but I was happy to find terrain in any
case.
Chris

On Fri, Feb 19, 2016 at 2:59 AM, Dominik Schneider <
Dominik.Schneider at colorado.edu> wrote:

> I need to calculate slope at different scales. In the case below, r is a
> 0.5deg resolution raster and I want the slope for 1.5 deg centered on each
> of those 0.5 deg pixels. I'm trying to estimate which side of mountain
> range each pixel is on. So the resulting raster would have the same number
> of pixels as r. The edges can be NA.
> any suggestions would be appreciated. Thanks
>
>
> r <- raster(nrows=22, ncols=20, xmn=-58, xmx=-48, ymn=-33, ymx=-22)
> setValues(r,rnorm(440))
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

[[alternative HTML version deleted]]

```