| 1 |
<!-- meta page description: Support for landscape index calculations on raster --> |
| 2 |
<h2>DESCRIPTION</h2> |
| 3 |
|
| 4 |
This documentation is focused on scientists and developers who wants to |
| 5 |
implement a new landscape index computation. Refer to the |
| 6 |
<a href="r.li.html">r.li</a> modules overview and |
| 7 |
<a href="g.gui.rlisetup.html">g.gui.rlisetup</a> module for user-focused |
| 8 |
documentation. |
| 9 |
|
| 10 |
<p> |
| 11 |
<!-- |
| 12 |
TODO: make this clear and rename daemon to library since it is library and not a daemon |
| 13 |
TODO: here can be just a really short intro and instructions how to get doxygen doc |
| 14 |
--> |
| 15 |
<em>r.li.daemon</em> provides support for landscape index calculations on raster |
| 16 |
maps. It hides the management of areas, defined using <a href="g.gui.rlisetup.html">g.gui.rlisetup</a> |
| 17 |
command. It is not used like a standalone program, but its functions are |
| 18 |
a library used by all <em>r.li.[index]</em> commands.<br> |
| 19 |
This description is a tutorial for new index definition. <br><br> |
| 20 |
The developer has only to focus on a unique area, like in mathematical definitions, and |
| 21 |
has to write a C implementation of it.<br> |
| 22 |
The areas are defined using a <em>struct</em> called <b>area_des</b> and it members are |
| 23 |
explained in the source code (doxygen) documentation. |
| 24 |
<p> |
| 25 |
To write a new index only two steps are needed: |
| 26 |
<ol> |
| 27 |
<li> |
| 28 |
Define a function and insert its declaration on file <b>index.h</b> in <em>r.li.daemon</em> |
| 29 |
folder, which contains all index declarations. This function must be of this kind: |
| 30 |
<div class="code"><pre> |
| 31 |
int index(int fd, char ** par, area_des ad, double * result) |
| 32 |
</pre></div> |
| 33 |
where: <ul> |
| 34 |
<li><i>fd</i> is the raster map descriptor</li> |
| 35 |
<li><i>par</i> is a matrix for special parameter (like argv in main)</li> |
| 36 |
<li><i>ad</i> is the area descriptor</li> |
| 37 |
<li><i>result</i> is where to put the index calculation result</li> |
| 38 |
</ul> |
| 39 |
This function has to return 1 on success and 0 otherwise. |
| 40 |
This function type is defined using typedef named <code>rli_func</code>.</li> |
| 41 |
<li> |
| 42 |
Create a main for command line arguments parsing, and call the function |
| 43 |
<div class="code"><pre> |
| 44 |
int calculateIndex(char *file, rli_func *f, |
| 45 |
char **parameters, char *raster, char *output); |
| 46 |
</pre></div> |
| 47 |
from the <i>r.li</i> library, for starting raster analysis.<br> |
| 48 |
It follows the meaning of parameters: |
| 49 |
<ul> |
| 50 |
<li><i>file</i> name of configuration file created using <a href="g.gui.rlisetup.html">g.gui.rlisetup</a></li> |
| 51 |
<li><i>f</i> pointer to index function defined above</li> |
| 52 |
<li><i>parameters</i> pointer to index special parameters</li> |
| 53 |
<li><i>raster</i> name of raster to use</li> |
| 54 |
<li><i>output</i> output file name</li> |
| 55 |
</ul></li> |
| 56 |
</ol> |
| 57 |
Compile it using a changed Makefile based on the file for <em>r.li.patchdensity</em>. |
| 58 |
|
| 59 |
<p> |
| 60 |
Refer to the <i>r.li</i> library documentation in the source code and |
| 61 |
implementation of <i>r.li</i> modules for details and examples. |
| 62 |
|
| 63 |
<h2>NOTES</h2> |
| 64 |
|
| 65 |
Using GRASS library function to access raster rows can slow down moving windows |
| 66 |
execution. It is recommended to use |
| 67 |
<br><div class="code"><pre> |
| 68 |
RLI_get_cell_row(int, int, area_des) |
| 69 |
RLI_get_fcell_row(int, int, area_des) |
| 70 |
RLI_get_dcell_row(int, int, area_des) |
| 71 |
</pre></div><br> |
| 72 |
to use an ad hoc build memory management developed to speed up the system. |
| 73 |
The documentation is in doxygen files. |
| 74 |
|
| 75 |
<h2>SEE ALSO</h2> |
| 76 |
|
| 77 |
<em><a href="https://grass.osgeo.org/gdp/landscape/r_le_manual5.pdf">old r.le manual</a></em><br> |
| 78 |
<em><a href="r.li.html">r.li</a></em> - package overview <br> |
| 79 |
<em><a href="g.gui.rlisetup.html">g.gui.rlisetup</a></em> |
| 80 |
|
| 81 |
<h2>REFERENCES</h2> |
| 82 |
|
| 83 |
McGarigal, K., and B. J. Marks. 1995. FRAGSTATS: spatial pattern |
| 84 |
analysis program for quantifying landscape structure. USDA For. Serv. |
| 85 |
Gen. Tech. Rep. PNW-351. (<a href="https://doi.org/10.2737/PNW-GTR-351">PDF</a>) |
| 86 |
|
| 87 |
<h2>AUTHORS</h2> |
| 88 |
|
| 89 |
Claudio Porta and Lucio Davide Spano, students of Computer Science |
| 90 |
University of Pisa (Italy).<br> |
| 91 |
Commission from Faunalia Pontedera (PI)<br> |
| 92 |
Rewritten from "r.le.setup" by William L. Baker<br> |
| 93 |
Various bug fixes by Markus Metz |