Skip to content

clustering multi band images

3 messages · Agustin Lobo, Laura Poggio, Dylan Beaudette

#
Laura Poggio escribi?:
.../...
You already did it in:
kl <- kmeans(as(img, "data.frame"), 5)

Perhaps you want to do it in 2 steps:

imgtabla <- as(img, "data.frame")
kl <- kmeans(imgtabla, 5)

You can look at the first rows of imgtabla with

imgtabla[1:5,]
or
head(imgtabla)
and then
dim(imgtabla)
summary(imgtabla)

If img were your complete Landsat image, the same steps
would yield an imgtabla with 262144 x 6 (as I assume you are not
using the thermal band). In that case, you probably want
to run PCA and use only the first 3 PCs for classification, as they 
typically
account for >95% of the total variance and you cam always apply
the inverse transform to the centroids to recover the original
metric.

As a matter of fact, I think it's more practical
here to convert imgtabla from data.frame to matrix, as all values are
numerical here.

Agus

  
    
#
If you are interested in a (supervised) imagery classification routine
that takes spatial arrangement into consideration, check out the
i.smap command in GRASS GIS.

Cheers,

Dylan
On Thu, Jun 12, 2008 at 4:57 AM, Laura Poggio <laura.poggio at gmail.com> wrote: