Some time ago I came across this post from Sylla Consult about a script to calculate forest fragmentation index suggested by Riitters et al. (2000). Obviously, it can be used for any land cover type, so perhaps landscape fragmentation index would be a better name. Anyway, the script r.forestfrag.sh is available from the GRASS-addons page.
Unfortunately, it only worked with GRASS 6.4. Because I mostly work in GRASS 7.0 I adapted the script to make it work on GRASS 7.0. I also added some additional options and changes:
- Added the option to select the size of the moving window (default is still 3×3)
- Before the areas statistics (r.report) is run, the output map is trimmed to remove the edge effect of the calculations with the moving window. However, there is the option to keep the output map trimmed or not
- Added the option to keep some of the intermediate layers (off by default).
I have added the new version of r.forestfrag.sh to https://svn.osgeo.org/grass/grass-addons/grass7/raster/r.forestfrag/ to make it easier for other to check / correct the script. The adapted version doesn’t run on GRASS 6.4 unfortunately, although it should be fairly easy to make it so.
Disclaimer: I only did some limited testing and on Linux only so I am not sure it will work on Windows.
![r.forestfrag [raster, forest, fragmentation-index, Riitters]_001](http://pvanb.files.wordpress.com/2013/02/r-forestfrag-raster-forest-fragmentation-index-riitters_001.png?w=300&h=294)
![r.forestfrag [raster, forest, fragmentation-index, Riitters]_002](http://pvanb.files.wordpress.com/2013/02/r-forestfrag-raster-forest-fragmentation-index-riitters_002.png?w=300&h=294)

Great! And thanks for pointing me to this index. Maybe when i have some free time i will implement it in python for QGis
It is a simple index so should be easy enough for you. I haven’t ventured into the world of python yet, but would like to convert this shell script to a GRASS python script. Something for later (if ever).
Hui, i just noticed that SAGA can also calculate the Riitters Fragmentation Index. The tool is under Grid – Analysis –> Fragmentation (Standard). It also works quite well in QGis via Sextante
Cool, I wonder what the difference is between the standard and alternative versions?
What does it mean ?
“It was written for GRASS 6.4 and because of changes in the syntax of some of the functions used by the script, it won’t work in GRASS 7.0.”
but then
“It doesn’t run on GRASS 6.4 unfortunately, although it should be fairly easy to make it so.”
It means that the original version was written for GRASS 6.4. The adapted version only works on GRASS 7.0 (for now,I might make it compatible with 6.4 when time allows).
Thanks for improving the script. I made the original GRASS script years ago. Glad to know other people are using it as well. Python versions (for QGIS and GRASS) should be easy to implement for those familiar with the language.