GRASS and windows console: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 24: | Line 24: | ||
==g.list output as input for another GRASS module== | ==g.list output as input for another GRASS module== | ||
Using | Using g.list output as input variable for another module. | ||
<source lang="bat"> | |||
C:\>FOR /F %c in ('g.list "type=raster" "pattern=*2" "mapset=user1" "separator=comma"') DO SET RASTER2REMOVE=%c | |||
C:\>echo %RASTER2REMOVE% | |||
b172,d172,it172,r172 | |||
C:\>g.remove type=raster name=%RASTER2REMOVE% | |||
The following data base element files would be deleted: | |||
raster/b172@user1 | |||
raster/d172@user1 | |||
raster/it172@user1 | |||
raster/r172@user1 | |||
WARNING: Nothing removed. You must use the force flag (-f) to actually | |||
remove them. Exiting. | |||
</source> | |||
[[Category: Development]] | [[Category: Development]] | ||
[[Category: WinGRASS]] | [[Category: WinGRASS]] |
Revision as of 18:19, 24 August 2018
This page shows extended examples how to run GRASS modules in the winGRASS windows console
Windows batch files in GRASS
In order to ease the workflow of analysis, several GRASS modules can be invoked at once by an batch file (*.bat) in the winGRASS windows console.
Python grass modules (e.g. v.db.addcolumn) have to be invoked by call in the batch-file.
@ECHO ON
g.region -p
v.in.region output=myreg
call v.db.addtable map=myreg
call v.db.addcolumn map=myreg columns="col1 double"
v.to.db map=myreg option=area columns=col1
Running batch files without starting up GRASS:
"%ProgramFiles?%\QGIS 2.18\bin\Grass72.bat" --exec MyScript.bat D:/myGrassData/MyLoc/MyMapset
g.list output as input for another GRASS module
Using g.list output as input variable for another module.
C:\>FOR /F %c in ('g.list "type=raster" "pattern=*2" "mapset=user1" "separator=comma"') DO SET RASTER2REMOVE=%c
C:\>echo %RASTER2REMOVE%
b172,d172,it172,r172
C:\>g.remove type=raster name=%RASTER2REMOVE%
The following data base element files would be deleted:
raster/b172@user1
raster/d172@user1
raster/it172@user1
raster/r172@user1
WARNING: Nothing removed. You must use the force flag (-f) to actually
remove them. Exiting.