[R-sig-Geo] focal() questions
Jonathan Greenberg
jgrn at illinois.edu
Tue Mar 27 17:02:37 CEST 2012
Robert and r-sig-geo'ers:
When working with raster's focal() function, I had a few questions:
1) How do I send non-spatial parameters to the function (e.g. similar
to the mapply "MoreArgs" parameter)?
2) Is it possible to have a non-raster return from the focal function?
For instance: I'm trying to code up a local maxima function that
returns the x,y position of all local maxima in an image (I want a
vector of these positions). I can do this in two steps by first
creating a raster of local maxima (e.g. placing "0" where a pixel is
not a local maxima), and then running through this raster and pull out
all pixels that are not 0. This, however, has to read two rasters and
write one. If I could identify a pixel as a local maxima within a
focal() function, and have it return the value as either a
SpatialPoints object or just an x,y coordinate, this would require
reading the image only once, and only writing where there are maxima.
Thoughts?
3) Can focal() be used with a rasterStack or rasterBrick, where the
filter and function is applied to multiple bands, rather than one at a
time? The "w" parameter would perhaps need to be an array or a list
of matrices. In this case, the function would be one that requires
all of the bands in the local neighborhood to operate.
--j
--
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html
More information about the R-sig-Geo
mailing list