Re: [R-sig-Geo] Assign a unique ID number to each patch in a raster

2017-02-26 Thread John Baumgartner
Yes, my gist mentioned by Agustin should do the trick. See the example in the comment at https://gist.github.com/johnbaums/6d155cfca28e02b05ad5. On Sun, 26 Feb 2017 at 21:42, Agustin Lobo wrote: > I think Nelly points out that package raster lacks a more general > > clumping tool (i.e., the equi

Re: [R-sig-Geo] Assign a unique ID number to each patch in a raster

2017-02-26 Thread Agustin Lobo
I think Nelly points out that package raster lacks a more general clumping tool (i.e., the equivalent to r.clump in grass) that I've often missed too. I'm not sure circumventing the way Ben suggest would work for large raster layers, for which package raster was designed. I have a note to myself re

Re: [R-sig-Geo] Assign a unique ID number to each patch in a raster

2017-01-26 Thread Ben Tupper
Hi, I think you are asking for connected component labeling. raster::clump() expects your features to be like islands surrounded by NA or 0 background. There might be more Raster* centric ways to do it, but you could use plain old vanilla image processing using the very good imager package ( h

[R-sig-Geo] Assign a unique ID number to each patch in a raster

2017-01-26 Thread Nelly Reduan
Hello, I would like to assign a unique ID number to each patch (a patch is composed of a set of adjacent cells) as shown in this figure: [cid:bab831e5-4246-4a77-884c-0012101662a5] I tested the clump function (package raster) by applying an eight adjacent cells rule but this function mixes all c