[R-sig-Geo] Fwd: clump of binary pixels on raster package

van Etten, Jacob (IRRI) J.vanEtten at cgiar.org
Mon May 11 01:56:47 CEST 2009


This seems to be a connected components problem, discussed recently on
this list.

Jacob.

-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of milton ruser
Sent: Monday, May 11, 2009 5:30 AM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] Fwd: clump of binary pixels on raster package

Dear all,

sorry for this double-posting, I know it is not a good idea,
but may be this list is more appropriated for this issue.

Thanks a lot

milton

---------- Forwarded message ----------
From: milton ruser <milton.ruser at gmail.com>
Date: Sat, May 9, 2009 at 5:59 PM
Subject: clump of binary pixels on raster
To: "r-help at r-project.org" <r-help at r-project.org>


Dear all,

I have a set od 30,000 binary landscapes, which represent habitat and
non-habitat cover.
I need to generate images that identify those neighbour (rule 8) pixels
as
one patch ID,
and a different patch ID for each clump of pixels. I coded it using
labcon(adehabitat),
but as some of my landscapes have so many patches, labcon not finish and
entry in
a eternal looping. By other side, I coded another solution using R &
grass
(r.clump),
but the solution is so slow, and as I need to run it a lot of time, I
will
need about 3 weeks
to finish... I was thinking if raster package could do the job fastly
than
R-grass.
Below you can find a simulation of what I need. On the second image,
each
color
have different values.

MyMatrix<-matrix(rep(0,100), ncol=10)
MyMatrix[2:4,3:6]<-1
MyMatrix[7:8,1:3]<-1
MyMatrix[8,7:8]<-1
MyMatrix[8,7:8]<-1
MyMatrix[6:7,8:9]<-1
x11(800,400)
par(mfrow=c(1,2))
image(MyMatrix)

MyClusters<-matrix(rep(0,100), ncol=10)
MyClusters[2:4,3:6]<-1
MyClusters[7:8,1:3]<-2
MyClusters[8,7:8]<-3
MyClusters[8,7:8]<-4
MyClusters[6:7,8:9]<-4
image(MyClusters, col=c("transparent", 1,3,4,5))

Regards a lot,

milton
brazil=toronto.

	[[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list