Just a python comment. (I'm not sure it will make any difference, but it makes the "run_command" cleaner)
See below:

On 05/15/2015 05:02 PM, Jake Chila wrote:
Actually, scratch that. The script ran once, but now when I run it from the GUI it doesn't actually update the table, it just runs through without doing anything.

JDC

On Fri, May 15, 2015 at 10:56 AM, Jake Chila <[email protected]> wrote:
HI all,



Here is the code I am running:

MAPS = grass.read_command('i.group',
                          group='LE7_SEG',
                          flags='g',
                          quiet=True).splitlines()


for maps in MAPS:
    
    band=maps.split('@',1)[0]

    bnum=band[-2:]
# Set variables for the column names
col = bnum+"_median"
qcol = "bright"+col



    grass.run_command('v.build',
                      map='LE7_2001_SEG',
                      option='build')
                      
    grass.run_command('v.rast.stats',
                      map='LE7_2001_SEG',
                      flags='c',
                      raster=band,
                      method='median',
                      column_prefix='%s' % bnum)
It seems to me that the '%s' is unnecessary here. bnum should already be a string variable so "column_prefix = bnum" should be fine.

   
    grass.run_command('v.db.update',
                      map='LE7_2001_SEG',
                      column='bright',
                      qcolumn='bright+%s_median' %bnum)

Here just use: "qcolumm = qcol"  (from above)

    
    grass.run_command('v.db.dropcolumn',
                      map='LE7_2001_SEG',
                      column = '%s_median' % bnum)

And here "column = col"  (from above)





Thanks,

JDC


_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to