[GRASS-user] python scripting using eclipse

Ismael Gómez gomez.ismael at gmail.com
Wed Jan 11 11:03:20 EST 2012


Hello everyone,


I would like to run some scripts using python. I am not a computer
scientist/engineer, just a python newbie, but I find that's a really
interesting matter.
Thus, I followed the instructions here:
http://grass.osgeo.org/wiki/Using_Eclipse_to_develop_GRASS_Python_programs
and doing so i was able to run from Eclipse the following simple script
under windows (WinGRASS 6.4RC2):


----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/env python
#
############################################################################
#
# MODULE:       model
#
# AUTHOR(S): ismael
#
# PURPOSE:      Script generated by wxGUI Graphical Modeler.
#
# DATE:         Mon Dec 19 18:49:29 2011
#
#############################################################################

import sys
import os
import atexit

import grass.script as grass

def cleanup():
    pass

def main():
    grass.run_command("v.extract --overwrite",
                      input = "parcelas at Modelo1a",
                      output = "parcelasLucrativas",
                      where = "Lucr=1")
    grass.run_command("v.overlay --overwrite",
                      ainput = "fincas at Modelo1a",
                      binput = "parcelasLucrativas",
                      output = "Xik",
                      operator = "and")

    return 0

if __name__ == "__main__":
    options, flags = grass.parser()
    atexit.register(cleanup)
    sys.exit(main())
----------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------


However, when I try to run it in linux (both Ubuntu 11.10 and Linux Mint 12
installations using the ppa repository) i always get error messages like
the following:

----------------------------------------------------------------------------------------------------------------------------------------------

Traceback (most recent call last):
  File
"/home/rosie/Dropbox/REPARCELIA-COMUN/GIS/script/GRASS/Modelo1a/modelo1a.py",
line 40, in <module>
    sys.exit(main())
  File
"/home/rosie/Dropbox/REPARCELIA-COMUN/GIS/script/GRASS/Modelo1a/modelo1a.py",
line 28, in main
    where = "Lucr=1")
  File "/usr/lib/grass64/etc/python/grass/script/core.py", line 176, in
run_command
    ps = start_command(*args, **kwargs)
  File "/usr/lib/grass64/etc/python/grass/script/core.py", line 164, in
start_command
    return Popen(args, **popts)
  File "/usr/lib/grass64/etc/python/grass/script/core.py", line 55, in
__init__
    startupinfo, creationflags)
  File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
    errread, errwrite)
  File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory


----------------------------------------------------------------------------------------------------------------------------------------------

Since my knowledge is still very limited, I've spent three days turnning
around it without success.

Could someone give me some hint on where to start to find a solution for
this, please?
Also: when I run it, how/where could I get more information on the
processes running further than those console messages? (sorry, i guess
that's more a Eclipse/Python question than a GRASS one)
Thank you very much in advance.

Regards,

Ismael G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20120111/1dde4277/attachment-0001.html


More information about the grass-user mailing list