R中kmeans的无监督分类
我有一个按时间顺序排列的卫星图像(5个波段),并想按R中的kmeans对其进行分类。我的脚本运行良好(循环浏览我的图像,将图像转换为data.frame,将它们聚类,然后将其转换回一个栅格): for (n in files) { image <- stack(n) image <- clip(image,subset) ###classify raster image.df <- as.data.frame(image) cluster.image <- kmeans(na.omit(image.df), 10, iter.max = 10, nstart = 25) ### kmeans, with 10 clusters #add back NAs using the NAs in band 1 (identic NA positions in all bands), see http://stackoverflow.com/questions/12006366/add-back-nas-after-removing-them/12006502#12006502 image.df.factor …