<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 30, 2014 at 4:33 PM, Charlie Shobe <span dir="ltr"><<a href="mailto:Charles.Shobe@colorado.edu" target="_blank">Charles.Shobe@colorado.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I have managed to figure it out, and I'm sharing the solution to hopefully clear up confusion for other beginners like myself. When specifying an SQL query for GRASS in Python, correct syntax in this case is:<div><br></div><div>where=""""dir"<0"""</div><div><br></div><div>Meaning, the entire expression should be enclosed in 3 quotation marks, and the names of any columns or attributes should be enclosed in a set of quotes as well. A number such as 0 requires to quotation marks.</div><div><br></div><div>I hope this helps someone avoid my confusion.</div><span class=""><font color="#888888"><div><br></div><div>Charlie</div></font></span></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 30, 2014 at 12:21 PM, Charlie Shobe <span dir="ltr"><<a href="mailto:Charles.Shobe@colorado.edu" target="_blank">Charles.Shobe@colorado.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi all,<br><br>I am attempting to extract a subset of points from a points vector based on the values in the column "dir". I am running GRASS 6.4.4 on Mac OS 10.9.5.<br><br>In the GRASS command line, I can successfully make my selection with the following command:<br>--------------------------------------------------------------<br>GRASS 6.4.4 (Yellowstone):~ > <b>v.extract input=streams_points output=outlets_vect type=point where="dir<0"</b></div></blockquote></div></div></div></div></blockquote><div><br></div><div><br></div><div>I can run similar command in GRASS 7 with sqlite backend without problems:</div><div>grass.run_command('v.extract', input='bridges@PERMANENT', where="width>150", output='bridges_extract') </div><div><br></div><div>perhaps try with sqlite if you don't use it already? Is it possible that the column name "dir" contains the quotes?</div><div><br></div><div>Anna</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><br>92 categories loaded from table <streams_points><br><br>Extracting features...<br><br>Building topology for vector map <outlets_vect>...<br><br>Registering primitives...<br><br>92 primitives registered<br><br>92 vertices registered<br><br>Building areas...<br><br> 100%<br><br>0 areas built<br><br>0 isles built<br><br>Attaching islands...<br><br>Attaching centroids...<br><br> 100%<br><br>Number of nodes: 92<br><br>Number of primitives: 92<br><br>Number of points: 92<br><br>Number of lines: 0<br><br>Number of boundaries: 0<br><br>Number of centroids: 0<br><br>Number of areas: 0<br><br>Number of isles: 0<br><br>Writing attributes...<br><br>v.extract complete.<br><br>-------------------------------------------------------<div>However, due to my incomplete knowledge of how Python and SQL interact, I am having trouble executing the same command in a Python script. Here is what I am trying:</div><div><br></div><div><b>g.run_command("v.extract", input="streams_points", output="outlets_vect", type="point", where="dir<0")</b><br></div><div><br></div><div>When I run this command, it fails to extract any points. I know that this must be due to some problem with the syntax of my SQL statement.</div><div><br></div><div>Can anyone clear this up for me?</div><div><br></div><div>Thanks,</div><div><br></div><div>Charlie</div></div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br></blockquote></div><br></div></div>