I'm struggling to make sense of the grass command line syntax for specifying a raster geotif as an input parameter for a watershed analysis using a DEM tif. I may also have the user folder setup, database, mapsets completely wrong too. The commands are to be run from the CMD in windows 10 using GRASS 7.6.

My command:

grass76 --text C:\Temp\grass\newLocation\PERMANENT --exec r.watershed -s elevation="C:\Temp\grass\database\dem.tif" threshold=10000 


Starting GRASS GIS...
WARNING: Concurrent mapset locking is not supported on Windows
Executing <r.watershed -s elevation=C:\Temp\grass\database\dem.tif threshold=10000> ...
SECTION 1a (of 5): Initiating Memory.
ERROR: Raster map <C:\Temp\grass\database\dem.tif> not found
WARNING: Subprocess failed with exit code 1
Execution of <r.watershed -s elevation=C:\Temp\grass\database\dem.tif threshold=10000> finished.
Cleaning up temporary files...
Press any key to continue . . .

I've tried without " around the filepath, with forward slashes, within <>.
I've copied the dem.tif to all the folders: 'C:\Temp\grass\newLocation', 'C:\Temp\grass\newLocation\command', 'C:\Temp\grass\newLocation\PERMANENT', 'C:\Temp\grass\database'

Any obvious syntax problems?

It seems like the --exec is successfully recognising I want to run a command put claims there is a raster file path or file access issue...

I want to avoid any setting up of a GRASS GIS Database directory, GRASS Location or a Mapset...whatever that is.

I just want to be able to run GRASS commands from the command prompt - in reality probably automated via python and subprocess and to change to input parameters such as the data source and output files. So I would prefer to do that via within the command itself. I want to avoid user input of setting up an environment.

Is that possible?

Have I mucked up the setup which is causing issues? (I set EPSG of 27700 when creating the user folder).

Current GRASS setup

  • If you don't want to import the taster file in a Grass location/mapset Use r.external ( Working with external data in GRASS 7)
    – gene
    Nov 5 '20 at 18:37
  • I had a go with that: grass76 r.external input=c:\grassdata\dem.tif output=dem. The result always tries to put my user folder in front of it and removes the filename. Result: ERROR: Location <C:\Users\aallan.BUROHAPPOLD\input=c:\grassdata> doesn't exist. The examples don't seem to mention filepaths or anything that looks like a windows filepath anyway.
    – GIS_py
    Nov 6 '20 at 9:47
  • BTW: please consider to upgrade to GRASS GIS 7.8: grass.osgeo.org/news/2020_10_05_grass_gis_7_8_4_released It comes with many (!) improvements.
    – markusN
    Nov 8 '20 at 17:19
  • I have grass 7.8 as well, and that doesn't help with the raster file paths issue. Does anyone have a working example with Windows file paths (and not in a user folder)? Preferably with spaces in the path, as this is a far more realistic- real world example when dealing with data from different sources...
    – GIS_py
    Nov 9 '20 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.