Yes it helps a lot.  From code point of view it works and it solved many
problems. Thank you very much.
However the results are quite different from what expected.
Then I am wondering if is it that the correct way to handle clustering of
remote sensing images.

Thanks

LP

2008/6/12 Roger Bivand <Roger.Bivand@nhh.no>:

> On Thu, 12 Jun 2008, Laura Poggio wrote:
>
>  Dear list,
>> I am trying to do some clustering on images. And I have two main problems:
>>
>> 1) Clustering multiband images.
>> I managed to be successful with a single band image, but when trying to
>> apply to a 3 band I get the following warning message:
>> In as.matrix.SpatialGridDataFrame(x) :
>>  as.matrix.SpatialPixelsDataFrame uses first column;
>> pass subset or [] for other columns
>>
>>
>> 2) saving clustering results as grid or image.
>> I get a vector of clusters, but without both coordinates. How it is
>> possible
>> to transform it in a grid?
>>
>> Here the code I use to read the image itself and to do the clustering:
>>
>> library(rgdal)
>> fld <- system.file("E:/data/IMG/fr/", package="rgdal")
>> img <- readGDAL("123_rawR.tif")
>>
>> kl <- kmeans(img, 5)
>>
>
> img is a SpatialGridDataFrame. kmeans() wants a matrix or data frame, so
> say:
>
> kl <- kmeans(as(img, "data.frame"), 5)
>
> Then
>
> img$cluster <- kl$cluster
>
> image(img, "cluster")
>
> Does this help?
>
> Roger
>
>
>> I am quite new to image processing, especially within R, and any help is
>> greatly appreciated.
>>
>> Thank you in advance
>>
>> LP
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of
> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand@nhh.no
>
>

	[[alternative HTML version deleted]]


