/
grass7.txt
172 lines (107 loc) · 8.09 KB
/
grass7.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
A short guide for creating and editing GRASS GIS 7 algorithms:
-----------------------------------------------------------------------
Each GRASS command, to be executed from a processing framework element such as the toolbox
or the graphical modeler, needs to be described to let it know the inputs
required by the commands, the output it generates and the parameters that are
used to configure it. Each command is described in a separate text file, although
some commands might be split in several algorithms, thus needing several files
and adding more than one new entry to the algorithms list. Splitting
a grass command is usually done because the processing provider does not support optional
parameters, so it will call GRASS using all parameters defined in the description
file.
Here is an explanation of the content of these descriptions files, so you can
create you own ones or edit current ones to improve them.
Each file starts with three lines containing:
- The name of the grass command to call to execute the algorithm (e.g. v.buffer)
- The description of the algorithm to show to the user. For split commands you must
include the algorithm id first, e.g.:
r.sun.insoltime - Solar irradiance and irradiation model (daily sums).
and
r.sun.incidout - Solar irradiance and irradiation model (for the set local time).
- The name of the group where you want the command to appear
After these three lines, a variable number of lines appear, describing all inputs
and outputs. Here is a brief explanation of the format of these lines, depending
on the type of parameter or output to be described. All declarations are contained
in a single line, with elements separated by the symbol "|"
- A raster layer
QgsProcessingParameterRasterLayer|[name of GRASS parameter]|[description of parameter to show]|[Default value, or None]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterRasterLayer|base|Name of input raster map|None|False
- A vector layer
QgsProcessingParameterFeatureSource|[name of GRASS parameter]|[description of parameter to show]|[A number indicating the type of geometry]|[Default value, or None]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterFeatureSource|input|Name of input vector map|-1|None|False
To indicate the type of geometry, use the following values:
-1: any geometry
0: points
1: lines
2: polygons
- Multiple layers
QgsProcessingParameterMultipleLayers|[name of GRASS parameter]|[description of parameter to show]|[A number indicating the type of geometry]|[Default value, or None]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterMultipleLayers|input|Input rasters|3|None|False
To indicate the type of geometry, use the following values:
-1: any vector geometry
0: points
1: lines
2: polygons
3: raster
- A file
QgsProcessingParameterFile|[name of GRASS parameter]|[description of parameter to show]|QgsProcessingParameterFile.File|[file extension|[Default value, or None]|[True/False, indicating if the parameter is optional or not]
- A numerical value
QgsProcessingParameterNumber|[name of GRASS parameter]|[description of parameter to show]|QgsProcessingParameterNumber.Integer or QgsProcessingParameterNumber.Double|[min value]|[max value]|[default value]|[True/False, indicating if the parameter is optional or not]
"None" can be used for both min and max values to indicate that there is no lower
or upper limit.
Example: QgsProcessingParameterNumber|levels|levels|QgsProcessingParameterNumber.Integer|1|256|32|False
- A numerical range
QgsProcessingParameterRange|[name of GRASS parameter]|[description of parameter to show]|QgsProcessingParameterNumber.Integer or QgsProcessingParameterNumber.Double|[default minimum and maximum values, separated by comma]|[True/False, indicating if the parameter is optional or not]
- A string
QgsProcessingParameterString|[name of GRASS parameter]|[description of parameter to show]|[default value]|[True/False, indicating if the parameter is optional or not]
- A value to select from a list
QgsProcessingParameterEnum|[name of GRASS parameter]|[description of parameter to show]|[list of possible values, separated by semicolons]|[True/False, indicating whether more than one value can be selected (allowMultiple)]|[zero-based index of default value]|[True/False, indicating if the parameter is optional or not]
- A boolean value
QgsProcessingParameterBoolean|[name of GRASS parameter]|[description of parameter to show]|[default value]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterBoolean|-p|Output values as percentages|False|True
- A pair of coordinates:
QgsProcessingParameterPoint[name of GRASS parameter]|[description of parameter to show]|[default value]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterPoint|coordinates|The coordinate of the center (east,north)|0,0|False
- A rectangular map extent:
QgsProcessingParameterExtent|[name of GRASS parameter]|[description of parameter to show]|[default value]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterExtent|bbox|Bounding box for selecting features|None|True
- A crs
QgsProcessingParameterCrs|[name of GRASS parameter]|[description of parameter to show]|[default value]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterCrs|crs|New coordinate reference system|None|False
- Outputs
Raster outputs are added with the following syntax:
QgsProcessingParameterRasterDestination|[name of GRASS output]|[description of output to show]|[Default value, or None]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterRasterDestination|length_slope|Slope length and steepness (LS) factor for USLE|None|True
Vector outputs are added with the following syntax:
QgsProcessingParameterVectorDestination|[name of GRASS output]|[description of output to show]|vector type|[Default value, or None]|[True/False, indicating if the parameter is optional or not]
The following types are available
QgsProcessing.TypeVectorLine
QgsProcessing.VectorLine
QgsProcessing.VectorPolygon
QgsProcessing.TypeVectorAnyGeometry
Example: QgsProcessingParameterVectorDestination|flowline|Flow line|QgsProcessing.TypeVectorLine|None|True
File outputs which are not layers or tables of a format supported by QGIS are added with the following syntax:
QgsProcessingParameterFileDestination|[name of GRASS output]|[description of output to show]|[file type]|[Default value, or None]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterFileDestination|reportfile|Final Report File|Txt files (*.txt)|None|True
A folder:
QgsProcessingParameterFolderDestination|[name of GRASS parameter]|[description of parameter to show]|[default value]|[True/False, indicating if the parameter is optional or not]
Example: QgsProcessingParameterFolderDestination|output_dir|Output Directory|None|False
- Advanced parameters
to tag a parameter as "advanced", just add "*" before its declaration. For instance:
*ParameterBoolean|-c|-c|True
ADVANCED OUTPUT PROCESSING
--------------------------
In some cases, it might be interesting to take the console output from GRASS and
extract a part of it for saving or formatting.
Two things can be done about this:
- Creating an HTML file with output. Just add an output of type OutputHTML.
It's value will not be passed to GRASS, but you can use it later to create the
HTML file from the console output. You should create a python file in the
grass/ext package, with the same name as the grass module, with dots replaced
by low hyphens (for instance r_quantile.py for the r.quantile command), and
add a postProcessResults(alg) method. It will be called when the execution of
the GRASS command is finished.
- Creating a text file. Do as above, but adding an output of type OutputFile.
Since some GRASS commands might use this type of output, and to make sure that
the value of this output is not passed to the GRASS command when calling it,
the output has to be named 'outputtext'