<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am trying to shade polygons for the COUNTY with the population when MALE > FEMALE from the shape file.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">But I can not get the correct SQL syntax for dbf.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Here are my python codes:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">#!C:/python26<o:p></o:p></p>
<p class="MsoNormal">import os<o:p></o:p></p>
<p class="MsoNormal">import os.path<o:p></o:p></p>
<p class="MsoNormal">import sys # the sys module [2]<o:p></o:p></p>
<p class="MsoNormal">from grass.script import core as grass # the core module [3]<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">def main(): <o:p></o:p></p>
<p class="MsoNormal"> if (os.environ['GISDBASE'] != ''):<o:p></o:p></p>
<p class="MsoNormal"> GISDBASE=os.environ['GISDBASE']<o:p></o:p></p>
<p class="MsoNormal"> else:<o:p></o:p></p>
<p class="MsoNormal"> GISDBASE='C:\\My Documents\\GIS DataBase'<o:p></o:p></p>
<p class="MsoNormal"> if (os.environ['LOCATION_NAME'] != ''):<o:p></o:p></p>
<p class="MsoNormal"> LOCATION_NAME=os.environ['LOCATION_NAME']<o:p></o:p></p>
<p class="MsoNormal"> else:<o:p></o:p></p>
<p class="MsoNormal"> LOCATION_NAME='nc_spm_08'<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> if (os.environ['MAPSET'] != ''):<o:p></o:p></p>
<p class="MsoNormal"> MAPSET=os.environ['MAPSET']<o:p></o:p></p>
<p class="MsoNormal"> else:<o:p></o:p></p>
<p class="MsoNormal"> MAPSET='PERMANENT'<o:p></o:p></p>
<p class="MsoNormal"> dbpath = os.path.join(GISDBASE, LOCATION_NAME, MAPSET, 'dbf')
<o:p></o:p></p>
<p class="MsoNormal"> if (len(sys.argv) > 2):<o:p></o:p></p>
<p class="MsoNormal"> os.environ['GRASS_PNGFILE'] = sys.argv[1]<o:p></o:p></p>
<p class="MsoNormal"> os.environ['GRASS_WIDTH'] = str(sys.argv[2])<o:p></o:p></p>
<p class="MsoNormal"> os.environ['GRASS_HEIGHT'] = str(sys.argv[3])<o:p></o:p></p>
<p class="MsoNormal"> else:<o:p></o:p></p>
<p class="MsoNormal"> os.environ['GRASS_PNGFILE'] = "default.png"<o:p></o:p></p>
<p class="MsoNormal"> os.environ['GRASS_WIDTH'] = str(300)<o:p></o:p></p>
<p class="MsoNormal"> os.environ['GRASS_HEIGHT'] = str(300) <o:p></o:p></p>
<p class="MsoNormal"> grass.run_command('v.in.ogr -o', dsn='C:\\News-GIS\\CUGIR_2011-11-02-13-51-10-642\\CEN2000nycty.036.shp.07865', output='from_shape')<o:p></o:p></p>
<p class="MsoNormal"> grass.run_command('db.connect', driver='dbf', database=dbpath)<o:p></o:p></p>
<p class="MsoNormal"> grass.run_command('g.region vect=from_shape -p')<o:p></o:p></p>
<p class="MsoNormal"> grass.run_command(<span style="background:yellow;mso-highlight:yellow">'v.db.select from_shape where="MALE > FEMALE"</span>')<o:p></o:p></p>
<p class="MsoNormal">­­­if __name__ == "__main__": # this allows the script to be used as a module in other scripts or as a standalone script<o:p></o:p></p>
<p class="MsoNormal"> sys.exit(main()) #<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Willie<o:p></o:p></p>
</div>
<p></p>
<p>The information contained in this communication is intended for the use<br>
of the designated recipients named above. If the reader of this <br>
communication is not the intended recipient, you are hereby notified<br>
that you have received this communication in error, and that any review,<br>
dissemination, distribution or copying of this communication is strictly<br>
prohibited. If you have received this communication in error, please <br>
notify The Associated Press immediately by telephone at +1-212-621-1898 <br>
and delete this email. Thank you.<br>
[IP_US_DISC]</p><br>
<p>msk dccc60c6d2c3a6438f0cf467d9a4938</p></body>
</html>