add multiband rasters in r
<p>i'm working with landsat data doing some topographic corrections using the method proposed by Hantson &amp; Chuvieco (2010) which involves a cover separation method based on a certain NDVI value to tell between vegetated and non-vegetated areas. </p>

<p>So, I go from having one multiband raster object to two, which are processed sepparately and subsequently combined to form the original, topographically corrected, scene. </p>

<p>The problem is that I have some NA values in the scene, so if I don't get rid of them I get a blank image as a result. I use the <code>sum</code> function with the <code>na.rm</code> option defined as TRUE to tackle this problem, but the result is a one-band raster object instead of a stack or rasterbrick object.</p>

<p>This is my code:</p>

<pre><code>#topographic correction
VEGB1TC&lt;- topocorr(VEGB1,slopeG,aspectG,sunelev,sunazimuth,method="ccorrection",na.value=NA)
VEGB2TC&lt;- topocorr(VEGB2,slopeG,aspectG,sunelev,sunazimuth,method="ccorrection",na.value=NA)
....        
SDB1TC&lt;- topocorr(SDB1,slopeG,aspectG,sunelev,sunazimuth,method="ccorrection",na.value=NA)
SDB2TC&lt;- topocorr(SDB2,slopeG,aspectG,sunelev,sunazimuth,method="ccorrection",na.value=NA)
...

#rasterize corrected band and stack them 
VB1&lt;-raster(VEGB1TC)
VB2&lt;-raster(VEGB2TC)
....

ADEVEG&lt;-stack(VB1, VB2,...)

SB1&lt;-raster(SDB1TC)
SB2&lt;-raster(SDB2TC)
....

ADESD&lt;-stack(SB1, SB2,...)

#-----------combine images-------

ADE&lt;-sum(stack(ADEVEG,ADESD),na.rm=T)
</code></pre>

<p>Is there a function that can add multiband rasters with a <code>na.rm</code> tag? I've found the <code>do.call</code> function but it seems to me that it sums several rasters into a single-band object. </p>

<p>Thanks for your help.</p>

<p>ps: Hantson, S. Chuvieco, E. 2010. Evaluation of different topographic correction methods for Landsat imagery. International Journal of Applied Earth Observations and Geoinformation 13(2011):691-700p.</p>