[GRASS-user] Re: [GRASS-dev] Helpp needed to call Grass from inside Python Plugin

Bishwarup Banerjee bishwarup.banerjee at gmail.com
Wed Mar 24 03:17:50 EDT 2010


Hello Markus,

I have tried to iimplement the example in my way. The code is as follows

import os
import sys
import core as grass

def main():
    input_map = options['H:/Shared_data/test1.tif']
    output_map = options['Test_24']
    ret = grass.run_command("r.in.gdal", input = input_map,  output =
output_map)
    sys.exit(ret)


if __name__ == "__main__":
    options, flags = grass.parser()
    main()

But I get the following error, I cant make out where I am going wrong. I
have set all the Env variables as suggested in the wiki page. Please help me
to implement it.


F:\GRASS-6-SVN\etc\python\grass\script>python test.py
Traceback (most recent call last):
  File "test.py", line 18, in <module>
    options, flags = grass.parser()
  File "F:\GRASS-6-SVN\etc\python\grass\script\core.py", line 359, in parser
    os.execvp("g.parser.exe", [name] + argv)
  File "F:\Quantum GIS\python\os.py", line 353, in execvp
    _execvpe(file, args)
  File "F:\Quantum GIS\python\os.py", line 389, in _execvpe
    func(fullname, *argrest)
OSError: [Errno 22] Invalid argument

With Regards
Bishwarup



On Wed, Mar 24, 2010 at 2:24 AM, Markus Neteler <neteler at osgeo.org> wrote:

> On Mon, Mar 22, 2010 at 1:28 PM, Bishwarup Banerjee
> <bishwarup.banerjee at gmail.com> wrote:
> > Hi All,
> >
> > I want to call the grass functionalities from inside my python plugins,
> in
> > QGIS
> > For example: the Grass's raster to polygon script, with out going inside
> the
> > grass plugin.
> > Can I set the Grass Mapset, and location from inside my python plugin?
> > Is this possible?
>
> I think yes. See also
> http://grass.osgeo.org/wiki/GRASS_and_Python
>
> (@all: please extend the Wiki page!)
>
> > my configurations are:
> > QGIS 0.11, GRASS 6.3, python 2.5, Windows
>
> Note that there are substantial improvements in GRASS 6.4+ for Python.
>
> Markus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20100324/f643d018/attachment.html


More information about the grass-user mailing list