counting the number of patches in a certain class

Jim Hinthorne geol1 at CWU.EDU
Thu Jan 26 14:39:11 EST 1995

>I have a map of 4 classes and I would like to know the fastest way 
>to find the number of patches (raster polygons) within each 
>class.  Thanks for any suggestions.
>Eric Lambert					
>ENE Division	         	OR		GIS Labratory/Geography
>P.O. Box 9005					318 Davenport Hall
>Champaign, IL 61826-9005			Urbana, IL 61801
>E-mail:lambert at			Lab#: (217) 333-5919
There is a program from U. Oregon (or Oregon St. U.) called "fragstats"
which does a nice job of this, as well as producing a myraid of other
statistics about rasters.  I'm not sure of the way to get it direct,
but I could send it to you, if you will contact me.  It has an excellent
manual in Postscript format, also.

One roundabout solution to your problem is to convert the raster map
to vector, then examine the vector attributes file in $LOCATION/dig_att
and count the attributes of each type.  A simple shell script or
awk script will do the trick.

Jim Hinthorne
geol1 at

More information about the grass-user mailing list