Generating Rate map in Grass

chuck ehlschlaeger crehlsc at ibm.net
Wed Aug 6 11:05:01 EDT 1997


Venkatesh,

> Can some one please tell me how I can generate a rate map in GRASS. I
> have
> a map with 3 categories (1,2,3) and I would like to generate raster
> layers
> showing how many times each category value occurs in a local
> neighbourhood
> (for example in 7x7 neigbourhood).

The following unix sequence can do this:

# set map name
set MAP = cat_map
# set number of categories to do (i.e., 20 cats assumes from 1-20)
set NUMCATS = 3
# set size equal to the neighborhood desired (i.e., 7 by 7 = 7)
set SIZE = 7
@ SIZE_SQRD = $SIZE * $SIZE
# Following code will sum cells from map $MAP
set CT = 1
while ( $CT <= $NUMCATS )
    r.mapcalc temp = 'if( $MAP == $CT , $SIZE_SQRD )'
    g.remove rast=rate$MAP$CT
    r.neighbors input=temp output=rate$MAP$CT method=average size=$SIZE
    @ CT = $CT + 1
end
# for descriptions of r.mapcalc and r.neighbors, see
http://www.cecer.army.mil/grass/userman/main-alpha.html

Sincerely, chuck
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vcard.vcf
Type: text/x-vcard
Size: 419 bytes
Desc: Card for Ehlschlaeger, Charles
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/19970806/c35b7637/vcard.vcf


More information about the grass-user mailing list