Reputation: 3
I have a raster with depth and I need to create a raster from it for incline and then stack the two rasters into a RasterStack. However I get this error:
Error in raster:stack(env, incline_rast) : NA/NaN argument
Here is my code:
#create incline raster from depth raster that is called env
incline_rast<-terrain(env,opt="slope")
## creating raster stack
stack <- raster:stack(env, incline_rast)
Error in raster:stack(env, incline_rast) : NA/NaN argument
stack <- raster:stack(env, incline_rast, quick = TRUE)
Error in raster:stack(env, incline_rast) : NA/NaN argument
The rasters have the same extent and coordinate system. What does this error mean and how to fix it? As I ma using R code to create one raster from another, why would it gve me an error?
How can I add information about the raster to make a reproducible example?
Upvotes: 0
Views: 1028
Reputation: 6516
Try raster::stack(env,incline_raster)
.
You are using the single colon in a wrong context:
A single colon :
is used to generate sequences, for example:
> 1:5
[1] 1 2 3 4 5
Whereas a double or triple colon ::
& :::
is used to access exported and internal variables:
package::function
For more information have a look here or here.
Simply load the package beforehand with library(raster)
or use the double colon ::
notation.
Upvotes: 3