By creating and running a script, you can perform a series of ILWIS operations. The usage of scripts may save time but is something for more experienced users.
With a script, MapCalc and TabCalc expressions can be performed as well as any ILWIS operation. Furthermore, some extra commands are possible to show objects, or to perform some file management. For more information on script syntax, see Appendices : ILWIS expressions, Appendices : ILWIS commands and Appendices : ILWIS script language (syntax).
To create a script:
The Script editor appears in which you can type your script expressions.
Example of a script with parameters:
To calculate slope maps in percentages and in degrees:
//script to calculate slope maps in percentages and in degrees
or type
Rem script to calculate slope maps in percentages and in degrees
%3 = MapInterpolContour(%1, %2)
Perform a contour interpolation on segment map %1, use existing georeference %2, and write the output to map %3.
Advanced users may wish to define a georeference corners beforehand with a script command; see Appendices : ILWIS script language (syntax).
DX = MapFilter(%3, dfdx)
Filter map %3 with the dfdx filter and write the output to map DX.
DY = MapFilter(%3, dfdy)
Filter map %3 with the dfdy filter and write the output to map DY.
%4 = 100 * HYP(DX,DY) / PIXSIZE(%3)
HYP is an internal MapCalc/TabCalc function;
DX and DY are the output maps from the filtering operation;
function PIXSIZE returns the pixel size of raster map %3;
%4 is the output map name of the map containing slope values in percentages.
%5 = RADDEG(ATAN(%4/100))
Function ATAN and RADDEG are internal MapCalc/TabCalc functions,
%5 is the output map name of the map containing slope values in degrees.
To let the script calculate the data files for the output maps, you may add the following lines to your script:
calc %3.mpr
calc %4.mpr
calc %5.mpr
In fact, by adding only calc %5.mpr, all maps which are part of the process to calculate map %5 will be calculated as well.
Parameter | Name | Type |
%1 | Input contour segment map | Segment Map |
%2 | Georef for all output maps | Georeference |
%3 | Output DEM | Filename |
%4 | Output slope map (perc.) | Filename |
%5 | Output slope map (degrees) | Filename |
For instance:
The Run Script dialog box will appear:
In the Run Script dialog box, all parameter names are listed as specified on the Parameters tab of the script editor.
Choose the objects etc. you wish to use, and click OK to execute the script.
Tips:
run Slopes Contour.mps MyGeoref.grf DEM SlopePct SlopeDeg
In script Slopes, %1 is filled out as Contour.mps, %2 as MyGeoref.grf, %3 as DEM, %4 as SlopePct, and %5 as SlopeDeg.
The result of running this script are maps SlopePct and SlopeDeg which are slope maps in percentages and in degrees. Also other maps are calculated during the whole procedure, such as the DEM, DX (height differences in X-direction) and DY (height differences in Y-direction). The following maps show the input map Contour and very small parts of the other maps calculated by the script.
Contour | DEM | |
DX | DY | |
Negative values in map DX mean that the slope is downwards when you go from west to east. A positive value indicates an upwards slope. In map DY positive values indicate that when you go from the south to north the slope is upwards and negative values mean that the slope is downwards.
SlopePct | SlopeDeg | |
The slope maps show the steepness of the slopes irrespective of the direction of the slope.
Mind:
the following slope values are the same: 30�= 58%, 45�= 100%, 60�= 173%, 80�= 567%. As you see, slope values in the Slopepct map can be greater than 100%.
Additionally, you can prepare representations for both maps with the Representation Value/Gradual editor.
You can also create two domain Groups to classify both output maps, e.g.:
classes 0-10%, 10-25%, 25-50%, 50-100%, >100% for the slope map in percentages and
classes 0-6�, 6-12.5�, 12.5-22.5�, 22.5-45�, >45� for the slope map in degrees.
Use these domain groups in the Slicing operation.
You can create your own Help for a script so that you can explain the meaning of parameters to other users of the script. For more information, see the Run Script dialog box.
See also:
Appendices : ILWIS script language (syntax)