[R-sig-Geo] How to reduce the buffering time with the function "buffer" (package raster)

Forrest Stevens r-sig-geo at forreststevens.com
Mon Apr 11 18:09:59 CEST 2016

Five million cells isn't all that many, how slow is too slow? Buffering a
raster of about 10 million cells on my laptop takes on the order of 20
seconds or so for a binary raster. Is it possible that you're fighting
memory problems?

In the past when doing multiple ring buffers I've found it faster to
calculate a distance-to raster first, and then apply multiple logical
comparisons on the distance raster.  I don't know if this applies to your
situation or not but it's one trick that might help.


On Mon, Apr 11, 2016 at 10:58 AM Nelly Reduan <nell.redu at hotmail.fr> wrote:

> Hello,
> I would like to build 100-m buffers (representing ecological corridors)
> around land cover attributes in a raster layer and to assign a given value
> (i.e., value of 13) to buffer cells.
> To do this, I'm using the function "buffer" (package raster) to draw the
> buffers around particular raster cells (i.e., cell values of 2 and 5). For
> example, in the image below, the buffers are represented in blue (cell
> values of 13) and the particular raster cells are represented in yellow
> (cell values of 2).
> The problem is that the time to run the function "buffer" is very low
> because I have a raster of 5000000 cells. Does anyone know how I can reduce
> the buffering time ?
> Thanks a lot for your time.
> Have a nice day.
> Nell
> [image: Capture.PNG]
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20160411/159ec27b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture.PNG
Type: image/png
Size: 12209 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20160411/159ec27b/attachment.png>

More information about the R-sig-Geo mailing list