[GRASS-windows] syntax for v.db.select run by grass.run_command

Liu, Huili HLiu at ap.org
Thu Mar 8 12:31:35 EST 2012


Hi,

I am trying to shade polygons for the COUNTY with the population when MALE > FEMALE from the shape file.

But I can not get the correct SQL syntax for dbf.

Here are my python codes:

#!C:/python26
import os
import os.path
import sys # the sys module [2]
from grass.script import core as grass # the core module [3]
def main():
    if (os.environ['GISDBASE'] != ''):
       GISDBASE=os.environ['GISDBASE']
    else:
       GISDBASE='C:\\My Documents\\GIS DataBase'
    if (os.environ['LOCATION_NAME'] != ''):
           LOCATION_NAME=os.environ['LOCATION_NAME']
    else:
       LOCATION_NAME='nc_spm_08'

    if (os.environ['MAPSET'] != ''):
       MAPSET=os.environ['MAPSET']
    else:
       MAPSET='PERMANENT'
    dbpath = os.path.join(GISDBASE, LOCATION_NAME, MAPSET, 'dbf')
    if (len(sys.argv) > 2):
         os.environ['GRASS_PNGFILE'] = sys.argv[1]
         os.environ['GRASS_WIDTH'] = str(sys.argv[2])
         os.environ['GRASS_HEIGHT'] = str(sys.argv[3])
    else:
         os.environ['GRASS_PNGFILE'] = "default.png"
         os.environ['GRASS_WIDTH'] = str(300)
         os.environ['GRASS_HEIGHT'] = str(300)
    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')
    grass.run_command('db.connect', driver='dbf', database=dbpath)
    grass.run_command('g.region vect=from_shape -p')
    grass.run_command('v.db.select from_shape where="MALE > FEMALE"')
if __name__ == "__main__": # this allows the script to be used as a module in other scripts or as a standalone script
    sys.exit(main()) #

Thanks,
Willie


The information contained in this communication is intended for the use
of the designated recipients named above. If the reader of this 
communication is not the intended recipient, you are hereby notified
that you have received this communication in error, and that any review,
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please 
notify The Associated Press immediately by telephone at +1-212-621-1898 
and delete this email. Thank you.
[IP_US_DISC]

msk dccc60c6d2c3a6438f0cf467d9a4938
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-windows/attachments/20120308/2d0b51a9/attachment.html


More information about the grass-windows mailing list