[GRASS-user] Python script in grass
Christian Kaiser
Christian.Kaiser at unil.ch
Sat Feb 6 05:19:36 EST 2010
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|9999')
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|9999" | 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 at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
More information about the grass-user
mailing list