[GRASS-user] [d.*] command not executing from standalone script

Ang Sherpa angsherpa232 at gmail.com
Sun Jan 8 02:06:16 PST 2017


Thanks Martin,

I tried with
from grass.script.setup import set_gui_path
    set_gui_path()

However, still no changes, the [d.*] doesnot starts. Am I missing something?
I have attached the script herewith this mail.

*Regards,*
*Ang Dawa Sherpa*
*GIS technician - Irrigation Master Plan*
*WRPPF - DOI, Nepal Government*
*Lalitpur*
*contact: 984 007 3861*

On Fri, Jan 6, 2017 at 5:11 PM, Martin Landa <landa.martin at gmail.com> wrote:

> Hi,
>
> 2017-01-06 6:22 GMT+01:00 Ang Sherpa <angsherpa232 at gmail.com>:
> > I tried to launch the script through the link you provided, however, it
> > throws and import error stating "No module named core.gcmd".
>
> you need to add wxGUI package to the path.
>
>     from grass.script.setup import set_gui_path
>     set_gui_path()
>
> Ma
>
> --
> Martin Landa
> http://geo.fsv.cvut.cz/gwiki/Landa
> http://gismentors.cz/mentors/landa
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20170108/2bbb7137/attachment.html>
-------------- next part --------------
#!/usr/bin/env python
import os
import sys
import time
import subprocess

gisdbase = os.path.join(os.path.expanduser("~"), "Documents\\grassdata")
location = "nc_spm_08_grass7"
mapset   = "user1"
gisbase  = os.environ['GISBASE'] = r'C:\Program Files\GRASS GIS 7.2.0'
sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "python"))

import grass.script.setup as gsetup
import grass.script as gscript
from grass.script.setup import set_gui_path


# setup your working environment
rcfile = gsetup.init(gisbase,gisdbase, location, mapset)
set_gui_path() 

# look what you have done so far
print "grass environment"
gscript.message('Current Grass GIS 7 enviornment:')
print gscript.gisenv()
##print '\n'
##print gtask.command_info('r.info')
print gscript.read_command('r.info',map='accum_5k')
gscript.run_command('d.mon',start='wx1',resolution='1')
gscript.run_command('d.rast',map='accum_5k')



os.remove(rcfile)



More information about the grass-user mailing list