[GRASS-user] Using Python in GRASS GIS for analysis

Hello Sir/Ma’am,

Warm Greetings.

I am Omkar Kadlag from Mumbai,India.I am pursuing Electronics and Telecommunication Engineering majors from K.J.Somaiya Institute of Engineering and Information Technology,Mumbai. I am working on a project “Watershed Analysis using python”.

While using GRASS GIS python console for analysis, I’m unable to get desired results. While giving the input ( as a DEM tile ) in the PowerShell prompt of GRASS GIS Software, it gives an error, as ‘wxpython file’ is not available.

Error -

Starting GRASS GIS…
Traceback (most recent call last):
File “C:\Program Files\GRASS GIS 7.8\gui\wxpython\gis_set.py”, line 43, in
from core.gcmd import GMessage, GError, DecodeString, RunCommand
File “C:\Program Files\GRASS GIS 7.8\gui\wxpython\core\gcmd.py”, line 43, in
from win32file import ReadFile, WriteFile
ImportError: DLL load failed: The specified procedure could not be found.
ERROR: Error in GUI startup. See messages above (if any) and if necessary, please report this error to the GRASS developers.
On systems with package manager, make sure you have the right GUI package, probably named grass-gui, installed.
To run GRASS GIS in text mode use the --text flag.
Use ‘–help’ for further options
grass78 --help
See also: https://grass.osgeo.org/grass78/manuals/helptext.html
Exiting…
Press any key to continue . . .

Then I made a new environment in the anaconda prompt, where I installed ‘wxpython’ and was successfully able to run GRASS GIS software, but now the issue is I can’t use the command prompt for my analysis. Then I tried to give inputs in the anaconda command prompt but was still unable to get correct outputs.

Error:
(base) PS C:\Users\Omkar> conda activate geopandas_env
(geopandas_env) PS C:\Users\Omkar> cd 'C:\Program Files'
(geopandas_env) PS C:\Program Files> grass78 --gui
Starting GRASS GIS…
WARNING: Concurrent mapset locking is not supported on Windows
Cleaning up temporary files…


/ / __ / | / / / / __/ / /
/ / __/ /
/ / /| | _
\
\ / / __ / / _

/ /
/ / , / ___ |
/ /
/ / / /
/ // / / /
_
/
/ |
/
/ |
/
// _///_/

Welcome to GRASS GIS 7.8.5
GRASS GIS homepage: https://grass.osgeo.org
This version running through: Command Prompt (C:\WINDOWS\system32\cmd.exe)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
See citation options with: g.version -x
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit

Launching GUI in the background, please wait…
Microsoft Windows [Version 10.0.19042.746]
(c) 2020 Microsoft Corporation. All rights reserved.

C:\Program Files>r.in.gdal -e input=“D:\NRSC\Month_Jan\ASTGTMV003_N19E073-dem” output=DEM
ERROR: Unable to open datasource <D:\NRSC\Month_Jan\ASTGTMV003_N19E073-dem>
C:\Program Files>

I want solutions where I can run GRASS GIS directly from the command line and implement my solutions on that.

Yours Sincerely,
Omkar.

Hello

Hello Sir/Ma’am,

Warm Greetings.

Then I made a new environment in the anaconda prompt, where I installed ‘wxpython’ and was successfully able to run GRASS GIS software, but now the issue is I can’t use the command prompt for my analysis. Then I tried to give inputs in the anaconda command prompt but was still unable to get correct outputs.

First I think you are mixing up running GRASS commands in python, versus the command prompt.
You do not necessarily need python (nor Anaconda) to run GRASS. Everything can be done from the command prompt or using the GRASS GUI. Furthermore, it’s a good idea, in my opinion, to begin learning the GRASS modules by running commands at the command prompt, then once you have the details worked out, shift to writing python scripts.

C:\Program Files>r.in.gdal -e input=“D:\NRSC\Month_Jan\ASTGTMV003_N19E073-dem” output=DEM
ERROR: Unable to open datasource <D:\NRSC\Month_Jan\ASTGTMV003_N19E073-dem>
C:\Program Files>

Here, clearly you did not specify the full file name to the ASTER DEM file. Probably the “.TIF” extension is missing? Can you check and enter the full file name, then get back to the list if you encounter any more problems.

···

Micha Silver
Ben Gurion Univ
Sde-Boker Remote Sensing Lab
cell: +972 (52) 3665918

See
https://github.com/OSGeo/grass/issues/1218

from win32file import ReadFile, WriteFile

{ImportError: DLL load failed: The specified procedure could not be >found.

This issue should be solved with winGRASS 7.8.5-2 standalone installer.

-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html