Hi, the problem Nathan described has been solved, and a new release of RSAGA (0.9-7) is now available on CRAN. The problem concerned the situation where radius >= 1 grid cells AND more than one input grid was used, i.e. most practical situations were not affected by this bug (e.g. applying a 'predict' method to a stack of input grids on a pixel-by-pixel basis was not affected because in this situation, radius = 0). Thanks again Nathan for your input. Best, Alex
On 27/05/2010 4:34 PM, Nathan Odgers wrote:
Hi, I have been trying to get the RSAGA multi.focal.function function to work in R. This is how I have been calling it: multi.focal.function(in.grids=filestack,out.grid.prefix="test_multi",path="z:/saga/stack",
fun=returnfirstline,in.varnames=c("elev_v","fix_v"),radius=3,search.mode="square",mw.to.vector=FALSE,mw.na.rm=FALSE)
where filestack is a vector containing the names of two grids: a DEM and another grid with integer values. The returnfirstline function prints (to the console) the arrays that multi.focal.function sends to returnfirstline. This is all very basic because for now I?m just trying to get a feel for how multi.focal.function works with multiple grids before I try and write a more complex function to use with it. In any case, this is the problem that I am having with it: everything seems to work in that returnfirstline prints the rectangular windows to the console output, but the problem is that multi.focal.function seems to set the first row of the input grids to NA values. This is what the header and first portion of the first four rows of the ascii DEM look like: ncols 202 nrows 202 xllcorner -50010.3411746 yllcorner 426994.8486065 cellsize 24.7883519 NODATA_value -9999 455 455 456 456 457 457 456 455 456 (?) 454 455 456 456 458 458 458 457 457 (?) 454 455 456 457 458 458 459 458 457 (?) 454 454 456 457 458 458 459 458 457 (?) And this is the first matrix window, derived from the DEM, that multi.focal.function passes to returnfirstline: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] NA NA NA NA NA NA NA [2,] NA NA NA NA NA NA NA [3,] NA NA NA NA NA NA NA [4,] NA NA NA NA NA NA NA [5,] NA NA NA 454 455 456 456 [6,] NA NA NA 454 455 456 457 [7,] NA NA NA 454 454 456 457 As you can see, the centre value of the matrix window is NA, which really should be the elevation 455 from the first row of the DEM. Any idea why this is happening, or am I just not understanding how to use multi.focal.function? Thanks, Nathan Nathan Odgers Postdoctoral Fellow?globalsoilmap.net West Virginia University Division of Plant and Soil Sciences National Soil Survey Center Geospatial Research Unit ph: +1 304 293 9839 [[alternative HTML version deleted]]
Alexander Brenning brenning at uwaterloo.ca - T +1-519-888-4567 ext 35783 Department of Geography and Environmental Management University of Waterloo 200 University Ave. W - Waterloo, ON - Canada N2L 3G1 http://www.fes.uwaterloo.ca/geography/faculty/brenning/