[R-sig-Geo] custom focal function on rasterstack

Jonathan Greenberg jgrn at illinois.edu
Tue Jun 24 19:25:04 CEST 2014


Hi Ben:

In the short term, I don't have a plan to implement a mask in focal
the way I think you are asking -- it has to do with how data is read
from disk to realize the parallel processing -- all of the data HAS to
be read, and you HAVE to have a single output per pixel.  With this
said, the code allows you to implement a mask if need be (set it as a
second input raster). If you use processing_unit="chunk" with a focal
window, you can efficiently use a mask to "skip" those masked pixels
(when I mean skip, I mean your function performs a quick "return NA"
instead of "process all values in the window").

The processing_unit="chunk" for focal takes a bit of getting used to,
so you might want to investigate it with debugmode=TRUE.  Another
trick for learning this mode is to grab the latest spatial.tools from
R-forge (version 1.4.4 or later) is to create a "GLT" file (a 2-band
file where band 1 is the pixel x position (column) and band 2 is the
pixel y position (row)) using raster_to_GLT.  When you take a look at
the test chunk in the debugmode you will see how this an "unspooled"
set of focal windows looks.

--j

On Tue, Jun 17, 2014 at 3:47 AM, ben mack <benjamin0mack at gmail.com> wrote:
> Hi,
>
> the spatial.tools is really a great thing to accellerate the raster
> processing. However, I have the same issue and often need to process only a
> part of the image and thus a mask option for the rasterEngine would also be
> great for me.
> I just wanted to also ask if this is considered an option in future versions
> (Jonathan?). Or did you, Ruben, or anybody else found a work around?
>
> Thanks a lot,
> Ben
>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/custom-focal-function-on-rasterstack-tp7585959p7586593.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007



More information about the R-sig-Geo mailing list