In the new JGrass console editor it is possible to:
- declare variables
- use variables in the scripts
- put the result of a command in a variable
- use string like in Java
- ... much more that I don't know jet!! :-)
The string that identifies the name of the main basin:
basemap = "chiese";
The output folder for the shapefiles I will create:
outputfolder = "/home/moovida/TMP/tmp/";
The name of the input shapefile:
inputmonitoringpoints = "/home/moovida/data/hydrocareworkspace/featuredata/utm/pti_monitoraggio.shp";
To read some maps which are already saved in the location just type the name of these maps, in this case the strings are a little complicated but managing them is very easy in this way:
drain = basemap + "_drain";
net = basemap + "_net_chnum";
pit = "bacino_" + basemap + "_pit";
netflow = basemap + "_net_flow";
nethackstream = basemap + "_net_hstr";
The output variables are initialized with the string name, everything could be added here...
netnumber = basemap + "_netnumber";
basin = basemap + "_basin";
basinoutput = outputfolder + "bacino_" + basemap + ".shp";
netoutput = outputfolder + "rete_" + basemap + ".shp";
And now just use the varibles in the JGrass command lines:
jgrass {
h.netnumbering --mode 2 --igrass-flow $drain --igrass-net $net --ishapefile-pointshape $inputmonitoringpoints --ograss-netnumber $netnumber --ograss-basin $basin
}
jgrass {
h.basinShape --igrass-pit $pit --igrass-basins $basin --oshapefile-basinshape $basinoutput
}
jgrass {
h.pfafstetter --mode 0 --igrass-flow $netflow --igrass-hacks $nethackstream --igrass-pit $pit --igrass-netnumber $netnumber --oshapefile-netshapeout $netoutput
}
Run the script with the specific RUN option in the right mouse button menu. In the console window you can see some messages to check the progress of the operations.
If someone has other interestig scripts it would be nice to put them here together.