I am facing some problems with NoData/NA while creating RSF-plot in R using raster data imported from ArcGIS 10.
My rasters are
a) Attributes of rivers (reclassified in ArcGIS 10 to0, 1 and NoData outside the rivers)
b) Distances from houses
I need the final map to be restricted to the rivers but somehow all the surrounding area is included in the resulting map, showing even highly qualified areas off the rivers. When plotting the single rasters of the rivers, they seem fine, with no hidden data outside the river
I guess the mistake somewhere happens where I sum the rasters. I assumed that when I sum rasters, only cells with no-NA data are included, but that might be my big mistake. How do I exclude therefore the areas outside the rivers in the easiest and effective way?
Below you find the script I am using.
# Import Raster to R using the library(raster)
Raster1 <-raster("Raster1")
Raster2 <-raster("Raster2")
Raster3 <-raster("Raster3")
RasterD <-raster("RasterD")
# Create a raster stack and do raster multiplications
model_stack<-raster::stack(Raster1,Raster2, Raster3, RasterD)
# assign the beta coefficients (stemming from glmer)
mean_search<-fixef(mod)
# multiply the rasters by the coefficients
model_stack_coef<-model_stack*mean_search
# Sum over all rasters - creates a single raster
pre_ssf <- calc(model_stack_coef, fun=sum)
# multiply by the power of exp
ssf<-calc(pre_ssf,fun=function(x){exp(x)})
# standardize between 0 and 1
ssf_p<-calc(ssf,fun=function(x){(x-min(x))/(max(x)-min(x))})