[GRASS-user] Python script in grass

2010-02-06 Thread Margherita Di Leo

Hi List,
please a little help with my python script. I don't know how to say in 
python:


echo 589541.859564|4473239.49338| | v.in.ascii output=outlet

Thank you
Cheers

--
Eng. Margherita Di Leo
Ph.D. Candidate
Methods and Technologies for Environmental Monitoring
Department of Environmental Engineering and Physics (DIFA)

University of Basilicata 
Campus Macchia Romana
85100 - Potenza 
Italy


Office: +39-0971205363
Fax: +39-0971205160





___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Python script in grass

2010-02-06 Thread Christian Kaiser
Ciao,

What you can do, is write your point into a temporary file and then read in 
again this file using v.in.ascii command. For example something like this:

import grass.script as grass
import os

# For temporary files
import tempfile as pytempfile

# For deleting temp directory
import shutil

# Create temporary directory
tmpdir = pytempfile.mkdtemp()
tmp_vec = tmpdir + '/vec.ascii'

fp = open(tmp_points, 'w')
fp.write('589541.859564|4473239.49338|')
fp.close()

# Read in your point
grass.run_command(v.in.ascii, input=tmp_vec, output=outmap, fs='|', skip=0, 
x=1, y=2, cat=3, columns='x double precision, y double precision, cat int')

# Remove the temporary directory and all the files in it
shutil.rmtree(tmpdir)


Of course, some error checking would be nice...

HTH
Christian



On 6 févr. 2010, at 10:55, Margherita Di Leo wrote:

 Hi List,
 please a little help with my python script. I don't know how to say in python:
 
 echo 589541.859564|4473239.49338| | v.in.ascii output=outlet
 
 Thank you
 Cheers
 
 -- 
 Eng. Margherita Di Leo
 Ph.D. Candidate
 Methods and Technologies for Environmental Monitoring
 Department of Environmental Engineering and Physics (DIFA)
 
 University of Basilicata Campus Macchia Romana
 85100 - Potenza Italy
 
 Office: +39-0971205363
 Fax: +39-0971205160
 
 
 
 
 
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user


___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Python script in grass

2010-02-06 Thread Glynn Clements

Margherita Di Leo wrote:

 please a little help with my python script. I don't know how to say in 
 python:
 
 echo 589541.859564|4473239.49338| | v.in.ascii output=outlet

To do it using the grass.script module:

grass.write_command('v.in.ascii', output = 'outlet',
stdin = 589541.859564|4473239.49338|)

or (more suitable when you want to feed a lot of data):

p = grass.feed_command('v.in.ascii', output = 'outlet')
p.stdin.write(589541.859564|4473239.49338|)
p.stdin.close()
p.wait()

-- 
Glynn Clements gl...@gclements.plus.com
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user