i.cluster(1)
โจ NAME โจ
okay so bestie, meet i.cluster โ a GRASS GIS module ๐. What it does: generates spectral signatures for land cover types in an image using a clustering algorithm ๐ฆ.
and then? the resulting signature file gets used as input for i.maxlik, to generate an unsupervised image classification. that's the whole glow-up arc, periodt ๐
๐ KEYWORDS ๐
imagery, classification, signatures โ that's the vibe check tag list, no notes โจ
๐ SYNOPSIS ๐
i.cluster
i.cluster --help
i.cluster group=name subgroup=name signaturefile=name classes=integer
[seed=name] [sample=rows,cols] [iterations=integer]
[convergence=float] [separation=float] [min_size=integer]
[reportfile=name] [--overwrite] [--help] [--verbose] [--quiet]
[--ui]
๐ฉ Flags:
--overwriteโ bestie this one lets output files overwrite existing files. yes, that means it will absolutely steamroll what's already there ๐--helpโ prints the usage summary so you're not out here guessing--verboseโ verbose module output, i.e. the module tells you everything it's doing, main character energy โจ--quietโ quiet module output, for when you want zero yapping ๐คซ--uiโ forces the GUI dialog to launch ๐
๐ Parameters:
group=name[required] โ name of input imagery groupsubgroup=name[required] โ name of input imagery subgroupsignaturefile=name[required] โ name for output file containing result signaturesclasses=integer[required] โ initial number of classes. options:1-255seed=nameโ name of file containing initial signaturessample=rows,colsโ number of rows and columns over which a sample pixel is takeniterations=integerโ maximum number of iterations. default:30convergence=floatโ percent convergence. options:0-100. default:98.0separation=floatโ cluster separation. default:0.0min_size=integerโ minimum number of pixels in a class. default:17reportfile=nameโ name for output file containing final report
๐ธ DESCRIPTION ๐ธ
i.cluster performs the first pass in the two-pass unsupervised classification of imagery, while the GRASS module i.maxlik executes the second pass. Both commands must be run to complete the unsupervised classification. it's a duo, not a solo act ๐ซ
i.cluster is a clustering algorithm (a modification of the k-means clustering algorithm) that reads through the (raster) imagery data and builds pixel clusters based on the spectral reflectances of the pixels (see Figure). those pixel clusters are imagery categories that can be related to land cover types on the ground. the spectral distributions of the clusters (e.g., land cover spectral signatures) are influenced by six parameters set by the user, and one relevant parameter you set is the initial number of clusters to be discriminated ๐
Fig.: Land use/land cover clustering of LANDSAT scene (simplified)
i.cluster starts by generating spectral signatures for this number of clusters and "attempts" to end up with this number of clusters during the clustering process. the resulting number of clusters and their spectral distributions, however, are also influenced by the range of the spectral values (category values) in the image files and the other parameters set by the user. those parameters are: the minimum cluster size, minimum cluster separation, the percent convergence, the maximum number of iterations, and the row and column sampling intervals ๐
the cluster spectral signatures that result are composed of cluster means and covariance matrices. these cluster means and covariance matrices are used in the second pass (i.maxlik) to classify the image. the clusters or spectral classes result can be related to land cover types on the ground. the user has to specify the name of group file, the name of subgroup file, the name of a file to contain result signatures, the initial number of clusters to be discriminated, and optionally other parameters (see below), where the group should contain the imagery files that the user wishes to classify. the subgroup is a subset of this group. the user must create a group and subgroup by running the GRASS program i.group before running i.cluster ๐ซถ
the subgroup should contain only the imagery band files that the user wishes to classify. note that this subgroup must contain more than one band file. the purpose of the group and subgroup is to collect map layers for classification or analysis. the signaturefile is the file to contain result signatures which can be used as input for i.maxlik. the classes value is the initial number of clusters to be discriminated; any parameter values left unspecified are set to their default values. no cap, that's the whole setup ๐
for all raster maps used to generate signature file it is recommended to have semantic label set. use r.support to set semantic labels of each member of the imagery group. signatures generated for one scene are suitable for classification of other scenes as long as they consist of same raster bands (semantic labels match). if semantic labels are not set, it will be possible to use obtained signature file to classify only the same imagery group used for generating signatures. so like, set your labels, bestie, future you will be obsessed ๐
๐ง Parameters: ๐ง
group=nameโ the name of the group file which contains the imagery files that the user wishes to classify.subgroup=nameโ the name of the subset of the group specified in thegroupoption, which must contain only imagery band files and more than one band file. the user must create a group and a subgroup by running the GRASS programi.groupbefore runningi.cluster.signaturefile=nameโ the name assigned to output signature file which contains signatures of classes and can be used as the input file for the GRASS programi.maxlikfor an unsupervised classification. this is the whole point, honestly ๐classes=valueโ the number of clusters that will initially be identified in the clustering process before the iterations begin.seed=nameโ the name of a seed signature file is optional. the seed signatures are signatures that contain cluster means and covariance matrices which were calculated prior to the current run ofi.cluster. they may be acquired from a previously run ofi.clusteror from a supervised classification signature training site section (e.g., using the signature file output byg.gui.iclass). the purpose of seed signatures is to optimize the cluster decision boundaries (means) for the number of clusters specified. it's giving "head start" energy ๐ฅsample=rows,colsโ these numbers are optional with default values based on the size of the data set such that the total pixels to be processed is approximately10,000(consider round up). the smaller these numbers, the larger the sample size used to generate the signatures for the classes defined. math is math ๐iterations=valueโ this parameter determines the maximum number of iterations, which is greater than the number of iterations predicted to achieve the optimum percent convergence. the default value is30. if the number of iterations reaches the maximum designated by the user, the user may want to reruni.clusterwith a higher number of iterations (seereportfile). default:30convergence=valueโ a high percent convergence is the point at which cluster means become stable during the iteration process. the default value is98.0percent. when clusters are being created, their means constantly change as pixels are assigned to them and the means are recalculated to include the new pixel. after all clusters have been created,i.clusterbegins iterations that change cluster means by maximizing the distances between them. as these means shift, a higher and higher convergence is approached. because means will never become totally static, a percent convergence and a maximum number of iterations are supplied to stop the iterative process. the percent convergence should be reached before the maximum number of iterations. if the maximum number of iterations is reached, it is probable that the desired percent convergence was not reached. the number of iterations is reported in the cluster statistics in the report file (seereportfile). default:98.0separation=valueโ this is the minimum separation below which clusters will be merged in the iteration process. the default value is0.0. this is an image-specific number (a "magic" number ๐ฎ) that depends on the image data being classified and the number of final clusters that are acceptable. its determination requires experimentation. note that as the minimum class (or cluster) separation is increased, the maximum number of iterations should also be increased to achieve this separation with a high percentage of convergence (seeconvergence). default:0.0min_size=valueโ this is the minimum number of pixels that will be used to define a cluster, and is therefore the minimum number of pixels for which means and covariance matrices will be calculated. default:17reportfile=nameโ thereportfileis an optional parameter which contains the result, i.e., the statistics for each cluster. also included are the resulting percent convergence for the clusters, the number of iterations that was required to achieve the convergence, and the separability matrix. basically the receipts ๐งพโจ
and that's part 1, bestie โ the vibe continues, so don't go anywhere ๐ฆ
๐ NOTES ๐
๐ธ Sampling method ๐ธ
okay so here's the tea, bestie โ i.cluster does not cluster all the pixels. it only clusters a sample (peep the sample parameter ๐). and the result of that clustering is not that every pixel gets assigned to a given cluster. essentially? you're only getting signatures that are representative of a given cluster. periodt.
so if you run i.cluster on the same data, asking for the same number of classes but with different sample sizes, you'll lowkey get slightly different signatures for each cluster every single run. not a bug, just the vibe โจ
๐ง Algorithm used for i.cluster ๐ง
the algorithm takes the input parameters you set at the start โ the initial number of clusters, the minimum distance between clusters, the correspondence between iterations you want, and the minimum size for each cluster. it also asks whether all pixels should be clustered, or every "x"th row and "y"th column (that's the sampling situation), plus the correspondence between iterations you're aiming for, and the max number of iterations to run. slay, so many knobs ๐
1st pass ๐ โ initial cluster means for each band get defined like this: the first cluster gets a value equal to the band mean minus its standard deviation, and the last cluster gets a value equal to the band mean plus its standard deviation. all the other cluster means are distributed equally spaced in between those two. then every pixel gets assigned to the class it's closest to, where distance = Euclidean distance. after that, all clusters less than your user-specified minimum distance get merged. and if a cluster has fewer than your user-specified minimum number of pixels? all those pixels get reassigned to the next nearest cluster, no cap. then new cluster means get calculated for each band as the average of the raster pixel values in that band for all the pixels present in that cluster. math girlies rise ๐ซถ
2nd pass ๐ฆ โ pixels get reassigned to clusters again, this time based on the new cluster means. then the cluster means get recalculated again. and this whole thing repeats until the correspondence between iterations reaches your user-specified level, or until the maximum number of iterations you specified runs out โ whichever comes first. it's giving loop, but make it fashion ๐
โจ EXAMPLE โจ
Preparing the statistics for unsupervised classification of a LANDSAT scene within the North Carolina project:
# Set computational region to match the scene
g.region raster=lsat7_2002_10 -p
# store VIZ, NIR, MIR into group/subgroup (leaving out TIR)
i.group group=lsat7_2002 subgroup=res_30m \
input=lsat7_2002_10,lsat7_2002_20,lsat7_2002_30,lsat7_2002_40,lsat7_2002_50,lsat7_2002_70
# generate signature file and report
i.cluster group=lsat7_2002 subgroup=res_30m \
signaturefile=cluster_lsat2002 \
classes=10 reportfile=rep_clust_lsat2002.txt
To complete the unsupervised classification, i.maxlik is subsequently used. See the example in its manual page ๐
the signature file you get from the example above will only let you classify the current imagery group (lsat7_2002). but if you wanna re-use that signature file to classify different imagery group(s)? totally doable, bestie โ just set semantic labels for each group member beforehand, i.e. before generating the signature files. semantic labels are set by means of r.support, like this:
# Define semantic labels for all LANDSAT bands
r.support map=lsat7_2002_10 semantic_label=TM7_1
r.support map=lsat7_2002_20 semantic_label=TM7_2
r.support map=lsat7_2002_30 semantic_label=TM7_3
r.support map=lsat7_2002_40 semantic_label=TM7_4
r.support map=lsat7_2002_50 semantic_label=TM7_5
r.support map=lsat7_2002_61 semantic_label=TM7_61
r.support map=lsat7_2002_62 semantic_label=TM7_62
r.support map=lsat7_2002_70 semantic_label=TM7_7
r.support map=lsat7_2002_80 semantic_label=TM7_8
๐ SEE ALSO ๐
- Image classification wiki page
- Historical reference also the GRASS GIS 4 Image Processing manual (PDF)
- Wikipedia article on k-means clustering (note that
i.clusteruses a modification of the k-means clustering algorithm)
r.support, g.gui.iclass, i.group, i.gensig, i.maxlik, i.segment, i.smap, r.kappa
๐ AUTHORS ๐
- Michael Shapiro, U.S. Army Construction Engineering Research Laboratory
- Tao Wen, University of Illinois at Urbana-Champaign, Illinois
- Semantic label support: Maris Nartiss, University of Latvia
๐ SOURCE CODE ๐
Available at: i.cluster source code (history)
Accessed: Saturday Jan 17 05:41:39 2026
Main index | Imagery index | Topics index | Keywords index | Graphical index | Full index
ยฉ 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
and that's the whole page, bestie!! ๐ซถ this is GRASS 8.4.2, i.cluster(1) โ go forth and cluster, you absolute icon ๐
โจ๐
๐ฆ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms