Send grass-windows mailing list submissions to
        grass-windows@lists.osgeo.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.osgeo.org/mailman/listinfo/grass-windows
or, via email, send a message with subject or body 'help' to
        grass-windows-requ...@lists.osgeo.org

You can reach the person managing the list at
        grass-windows-ow...@lists.osgeo.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of grass-windows digest..."


Today's Topics:

   1. syntax for v.db.select run by grass.run_command (Liu, Huili)
   2. Re: syntax for v.db.select run by grass.run_command
      (Markus Neteler)
   3. RE: syntax for v.db.select run by grass.run_command (Liu, Huili)


----------------------------------------------------------------------

Message: 1
Date: Thu, 8 Mar 2012 17:31:35 +0000
From: "Liu, Huili" <h...@ap.org>
Subject: [GRASS-windows] syntax for v.db.select run by
        grass.run_command
To: "grass-windows@lists.osgeo.org" <grass-windows@lists.osgeo.org>
Message-ID:
        <edbb02efb114934ea2fa741873e8a5251344f...@ctcxmbx01.ap.org>
Content-Type: text/plain; charset="us-ascii"

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-0001.html

------------------------------

Message: 2
Date: Thu, 8 Mar 2012 22:46:53 +0100
From: Markus Neteler <nete...@osgeo.org>
Subject: Re: [GRASS-windows] syntax for v.db.select run by
        grass.run_command
To: "Liu, Huili" <h...@ap.org>
Cc: "grass-windows@lists.osgeo.org" <grass-windows@lists.osgeo.org>
Message-ID:
        <CALFmHhscZf4fEd=g8sdtgu604fdzs2f4d8dtzekso_x761f...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Thu, Mar 8, 2012 at 6:31 PM, Liu, Huili <h...@ap.org> wrote:
...
>
> I am trying to shade polygons for the COUNTY with the population when
> MALE > FEMALE from the shape file.
...
>     grass.run_command('v.db.select from_shape where="MALE > FEMALE"')

Please check here for a working implementation :

http://trac.osgeo.org/grass/browser/grass/trunk/scripts/v.report/v.report.py#L92

It uses
p = grass.pipe_command('v.db.select', quiet = True, flags='c', map =
mapname, layer = layer)

Markus


------------------------------

Message: 3
Date: Fri, 9 Mar 2012 14:46:09 +0000
From: "Liu, Huili" <h...@ap.org>
Subject: RE: [GRASS-windows] syntax for v.db.select run by
        grass.run_command
To: Markus Neteler <nete...@osgeo.org>
Cc: "grass-windows@lists.osgeo.org" <grass-windows@lists.osgeo.org>
Message-ID:
        <edbb02efb114934ea2fa741873e8a5252370d...@ctcxmbx02.ap.org>
Content-Type: text/plain; charset="iso-8859-1"

Thanks Markus. That is a great example to generate a report.
DBF driver doesn't support for join tables so I have to add a color column in 
the table to shade polygon. But 
grass.run_command('v.db.addcol', map='from_shape', columns='WINNER_COLOR, 
VARCHAR()') requires awk. After I installed awk, it still show the same error. 
awk is in environment variable and ran fine by cmd. Not sure if it is a bug on 
Windows.

Regards,
Willie





-----Original Message-----
From: grass-windows-boun...@lists.osgeo.org 
[mailto:grass-windows-boun...@lists.osgeo.org] On Behalf Of Markus Neteler
Sent: Thursday, March 08, 2012 4:47 PM
To: Liu, Huili
Cc: grass-windows@lists.osgeo.org
Subject: Re: [GRASS-windows] syntax for v.db.select run by grass.run_command

On Thu, Mar 8, 2012 at 6:31 PM, Liu, Huili <h...@ap.org> wrote:
...
>
> I am trying to shade polygons for the COUNTY with the population when 
> MALE > FEMALE from the shape file.
...
>     grass.run_command('v.db.select from_shape where="MALE > FEMALE"')

Please check here for a working implementation :

http://trac.osgeo.org/grass/browser/grass/trunk/scripts/v.report/v.report.py#L92

It uses
p = grass.pipe_command('v.db.select', quiet = True, flags='c', map = mapname, 
layer = layer)

Markus
_______________________________________________
grass-windows mailing list
grass-windows@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-windows


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



------------------------------

_______________________________________________
grass-windows mailing list
grass-windows@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-windows


End of grass-windows Digest, Vol 64, Issue 4
********************************************

Reply via email to