Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

terra shade function not stacking different angles and directions with my own data (as per example)

$
0
0

I have tried to replicate the las t section of the example from the shade function in terra with my own data to improve the hillshade with the use of several directions and angles, but the resulting object has no values. And therefore, no mean is produced with the Reduce function. The object with the simple shade parameter (with one angle and direction, as per the example) works fine.

There is no error message whatsoever, just no values in the final output raster as show below. not sure if this is because of a size limitation of terra (maybe?).

My code:

library(terra)elevation <- terra::rast(file.choose())alt<- terra::mask(elevation, bcr)alt <- terra::disagg(alt, 10, method="bilinear")slope <- terra::terrain(alt, "slope", unit="radians")aspect <- terra::terrain(alt, "aspect", unit="radians")#basic hillshadehill <- terra::shade(slope, aspect, 40, 270)terra::plot(hill)terra::plot(hill, col=grey(0:100/100), legend=FALSE, mar=c(2,2,1,4))#get a better shade with different angles and directionsh <- terra::shade(slope, aspect, angle = c(45, 45, 45, 80), direction = c(225, 270, 315, 135))h <- Reduce(mean, h)            terra::plot(h)

Either before the Reduce or after, h has this output (and its seems to run in less than a second, which is not the case for run with only 1 angle and direction, hill):

hclass       : SpatRaster dimensions  : 18640, 15930, 1  (nrow, ncol, nlyr)resolution  : 100, 100  (x, y)extent      : -2791000, -1198000, 1522000, 3386000  (xmin, xmax, ymin, ymax)coord. ref. : +proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs 

The elevation I am trying to use could be found here:https://drive.google.com/file/d/12yezqqNutfD19eyxJmbL9WqvwTdcjT3e/view?usp=sharing

Any input would be appreciated!

Cheers and Thanks!!


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>