<div dir="ltr"><div>Hi,<br></div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 17, 2013 at 3:39 PM, Pietro <span dir="ltr"><<a href="mailto:peter.zamb@gmail.com" target="_blank">peter.zamb@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Johannes,<br>
<div class="im"><br>
On Mon, Jun 17, 2013 at 1:24 PM, Johannes Radinger<br>
<<a href="mailto:johannesradinger@gmail.com">johannesradinger@gmail.com</a>> wrote:<br>
> I want to create a point via python at a specific location using the<br>
> v.in.ascii command. How can I also specify the colum names or how can a<br>
> header be used in combination with the standard input. As it is only one<br>
> single point I don't want to create a txt file containing the header and the<br>
> info. I tried following in GRASS7:<br>
<br>
</div>I think that some of your parameters are not correct...<br>
<br>
{{{<br>
from grass.pygrass.modules import Module<br>
<br>
ASCII = """cat,X,Y,Name<br>
1,635828.3,223067.0,pub<br>
2,643553.4,220711.5,pizzeria"""<br>
<br>
COLS = 'cat int, x double precision, y double precision, name varchar(10)'<br>
<br>
vina = Module('v.in.ascii', input='-', output='pnt__v_in_ascii',<br>
                        format='point', separator=',', skip=1, x=2, y=3, cat=1,<br>
                        columns=COLS, stdin_=ASCII, overwrite=True,<br>
finish_=True)<br>
}}}<br>
<br></blockquote><div><br><br></div><div>I thought I found the problem by seeing the difference between the parameter: "stdin_" and<br></div><div>"stdin". However here the result with "_":<br>
<br>grass.write_command("v.in.ascii",<br>        overwrite=True,<br>        format="point",<br>        #flags="n",<br>        input="-",<br>        cat=1,<br>        x=2,<br>        y=3,<br>
        stdin_=ascii,<br>        columns=cols,<br>        output="mypoint",<br>        separator=",")<br>Traceback (most recent call last):<br>  File "<input>", line 12, in <module><br>
  File "/usr/local/grass-7.0.svn/etc/python/grass/script/core.py", line 331, in write_command<br>    stdin = kwargs['stdin']<br>KeyError: 'stdin'<br><br></div><div>So I tried without:<br></div><div>
<br></div><div>ascii = """cat,X,Y,Name<br>1,10:20:08E,53:25:27N,mypoint"""<br><br>cols = 'cat int, x varchar(10), y varchar(10), name varchar(10)'<br><br>grass.write_command("v.in.ascii",<br>
        overwrite=True,<br>        format="point",<br>        #flags="n",<br>        input="-",<br>        cat=1,<br>        x=2,<br>        y=3,<br>        stdin=ascii,<br>        columns=cols,<br>
        output="mypoint",<br>        separator=",")<br><br></div><div>which at least executes but gives me following error: GRASS_INFO_ERROR(13239,2): Unparsable longitude value in column num 2: X<br><br>
</div><div>Everything seems to be similar to your example except for the fact that I am using lat/long values instead of projected double precision X <br>Y coordinates.<br><br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

Mostly with the same parameters you can run grass.write_command.<br>
But If you are looking for a tool to "play" and experiment I highly<br>
suggest pygrass:<br>
<br>
{{{<br>
from grass.pygrass.vector import VectorTopo<br>
from grass.pygrass.geometry import Point<br>
<br>
new = VectorTopo('mynewvect')<br>
COLS = [(u'cat',       'INTEGER PRIMARY KEY'),  (u'name',      'VAR CHAR')]<br>
new.open('w', tab_cols=COLS)<br>
new.write(Point(635828.3, 223067.0), ('pub', ))<br>
new.write(Point(643553.4, 220711.5), ('restaurant', ))<br>
new.close()<br>
<br>
new.open('r')<br>
<a href="http://new.cat" target="_blank">new.cat</a>(1).attrs['name']  # return: pub<br>
new.close()<br>
}}}<br>
<br>
If you are interested please have a look of the ipython notebook:<br>
<br>
<a href="https://github.com/zarch/workshop-pygrass" target="_blank">https://github.com/zarch/workshop-pygrass</a><br>
<br>
you have just to clone, and from a running session of grass enter in<br>
the directory and launch:<br>
<br>
> ipython notebook<br>
<br>
to have a briefly introduction to the library.<br>
<br>
Have fun!<br>
<span class=""><font color="#888888"><br>
Pietro<br>
</font></span></blockquote></div><br></div></div></div>