[GRASS-SVN] r58106 - in grass-addons/grass7/vector: . v.transects

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 25 10:27:00 PDT 2013


Author: annakrat
Date: 2013-10-25 10:27:00 -0700 (Fri, 25 Oct 2013)
New Revision: 58106

Added:
   grass-addons/grass7/vector/v.transects/
   grass-addons/grass7/vector/v.transects/v.transects.html
Removed:
   grass-addons/grass7/vector/v.transects/description.html
Modified:
   grass-addons/grass7/vector/v.transects/v.transects.py
Log:
v.transects ported to GRASS7 (plus whitespace changes for PEP8 compliance)

Deleted: grass-addons/grass7/vector/v.transects/description.html
===================================================================
--- grass-addons/grass6/vector/v.transects/description.html	2013-10-15 23:19:37 UTC (rev 58010)
+++ grass-addons/grass7/vector/v.transects/description.html	2013-10-25 17:27:00 UTC (rev 58106)
@@ -1,69 +0,0 @@
-<h2>DESCRIPTION</h2><em>v.transects</em> creates equally spaced geometries along 
-input lines. The geometries can be lines or quadrilateral areas. Lines 
-and areas are generated to be perpendicular to the input line. 
-
-
-<h2>NOTES</h2>Input vector lines that are shorter than <b>transect_spacing</b> are ignored. 
-<p>
-<b>transect_spacing</b>, <b>dleft</b>, and <b>dright</b> are interpreted to be in horizontal map units (e.g., degrees in the WGS84 projection). 
-<p>
-<em><b>v.transects</b></em> may fail for a network of lines in Windows.
-
-<h2>EXAMPLES</h2>In these examples, the 
-<a href="http://courses.ncsu.edu/mea582/common/media/01/NagsHead_series.zip"><font color="0000FF">Nags Head (19MB)</font></a>
-mapset is used to generate a shoreline and shore-perpendicular geometries. To use the mapset, unpack it into the 
-<a href="http://courses.ncsu.edu/mea582/common/media/01/nc_spm_08.zip"><font color="0000FF">nc_spm_08 (150MB)</font></a>
-Location or the
-<a href="http://courses.ncsu.edu/mea792/common/media/gisdemo.zip"><font color="0000FF">gisdemo (47MB)</font></a>
-Location.
- 
-
-<h3>Example 1) - Generate line transects along shoreline</h3>
-
-<p>Generate 20 cross-shore transects along 2008 shoreline (1m contour)<br>
-<div class=code><pre>g.region rast=NH_2008_1m
-r.contour input=NH_2008_1m output=NH_2008_1m level=1 cut=100
-v.report map=NH_2008_1m option=length
-# cat|level|length
-# 1|1|1037.86684790028
-# 1038m / 20transects = 52m per transect (value for transect_spacing)
-v.transects input=NH_2008_1m output=NH_2008_transects transect_spacing=52
-v.info NH_2008_transects
-</pre></div>
-
-<h3>Example 2) - Generate line transects specifying the left and right length</h3>
-
-<p>Generate longer, more parallel transects by specifying dleft and dright and 
-smoothing the input line<br>
-<div class=code><pre>g.region rast=NH_2008_1m
-r.contour input=NH_2008_1m output=NH_2008_1m level=1 cut=100
-v.generalize input=NH_2008_1m output=NH_2008_1m_smoothed \
-  method=sliding_averaging look_ahead=201
-v.transects input=NH_2008_1m_smoothed \
-  output=NH_2008_transects_long_smoothed transect_spacing=52 \
-  dleft=20 dright=300
-</pre></div>
-
-<h3>Example 3) - Generate area transects along shoreline</h3>
-
-<p>Generate longer, more parallel transects by specifying dleft and dright and 
-smoothing the input line<br>
-<div class=code><pre>g.region rast=NH_2008_1m
-r.contour input=NH_2008_1m output=NH_2008_1m level=1 cut=100
-v.transects input=NH_2008_1m output=NH_2008_areas \
-  transect_spacing=52 dleft=20 dright=300 type=area
-v.db.addtable NH_2008_areas
-v.db.addcolumn map=NH_2008_areas columns='demStats DOUBLE PRECISION'
-v.rast.stats vector=NH_2008_areas raster=NH_2008_1m column_prefix=NH2008
-v.db.select NH_2008_areas
-</pre></div>
-
-
-<h2>SEE ALSO</h2><em>
-<a href="http://www4.ncsu.edu/~ejhardi2/v.generalize.html">v.generalize</a>, 
-<a href="http://www4.ncsu.edu/~ejhardi2/r.transect.html">r.transect</A> </em>
-
-
-<h2>AUTHOR</h2>Eric Hardin, Helena Mitasova, Updates by John Lloyd 
-<p>
-<i>Last changed: $Date$</i>

Copied: grass-addons/grass7/vector/v.transects/v.transects.html (from rev 58010, grass-addons/grass6/vector/v.transects/description.html)
===================================================================
--- grass-addons/grass7/vector/v.transects/v.transects.html	                        (rev 0)
+++ grass-addons/grass7/vector/v.transects/v.transects.html	2013-10-25 17:27:00 UTC (rev 58106)
@@ -0,0 +1,69 @@
+<h2>DESCRIPTION</h2><em>v.transects</em> creates equally spaced geometries along 
+input lines. The geometries can be lines or quadrilateral areas. Lines 
+and areas are generated to be perpendicular to the input line. 
+
+
+<h2>NOTES</h2>Input vector lines that are shorter than <b>transect_spacing</b> are ignored. 
+<p>
+<b>transect_spacing</b>, <b>dleft</b>, and <b>dright</b> are interpreted to be in horizontal map units (e.g., degrees in the WGS84 projection). 
+<p>
+<em><b>v.transects</b></em> may fail for a network of lines in Windows.
+
+<h2>EXAMPLES</h2>In these examples, the 
+<a href="http://courses.ncsu.edu/mea582/common/media/01/NagsHead_series.zip"><font color="0000FF">Nags Head (19MB)</font></a>
+mapset is used to generate a shoreline and shore-perpendicular geometries. To use the mapset, unpack it into the 
+<a href="http://courses.ncsu.edu/mea582/common/media/01/nc_spm_08.zip"><font color="0000FF">nc_spm_08 (150MB)</font></a>
+Location or the
+<a href="http://courses.ncsu.edu/mea792/common/media/gisdemo.zip"><font color="0000FF">gisdemo (47MB)</font></a>
+Location.
+ 
+
+<h3>Example 1) - Generate line transects along shoreline</h3>
+
+<p>Generate 20 cross-shore transects along 2008 shoreline (1m contour)<br>
+<div class=code><pre>g.region rast=NH_2008_1m
+r.contour input=NH_2008_1m output=NH_2008_1m level=1 cut=100
+v.report map=NH_2008_1m option=length
+# cat|level|length
+# 1|1|1037.86684790028
+# 1038m / 20transects = 52m per transect (value for transect_spacing)
+v.transects input=NH_2008_1m output=NH_2008_transects transect_spacing=52
+v.info NH_2008_transects
+</pre></div>
+
+<h3>Example 2) - Generate line transects specifying the left and right length</h3>
+
+<p>Generate longer, more parallel transects by specifying dleft and dright and 
+smoothing the input line<br>
+<div class=code><pre>g.region rast=NH_2008_1m
+r.contour input=NH_2008_1m output=NH_2008_1m level=1 cut=100
+v.generalize input=NH_2008_1m output=NH_2008_1m_smoothed \
+  method=sliding_averaging look_ahead=201
+v.transects input=NH_2008_1m_smoothed \
+  output=NH_2008_transects_long_smoothed transect_spacing=52 \
+  dleft=20 dright=300
+</pre></div>
+
+<h3>Example 3) - Generate area transects along shoreline</h3>
+
+<p>Generate longer, more parallel transects by specifying dleft and dright and 
+smoothing the input line<br>
+<div class=code><pre>g.region rast=NH_2008_1m
+r.contour input=NH_2008_1m output=NH_2008_1m level=1 cut=100
+v.transects input=NH_2008_1m output=NH_2008_areas \
+  transect_spacing=52 dleft=20 dright=300 type=area
+v.db.addtable NH_2008_areas
+v.db.addcolumn map=NH_2008_areas columns='demStats DOUBLE PRECISION'
+v.rast.stats vector=NH_2008_areas raster=NH_2008_1m column_prefix=NH2008
+v.db.select NH_2008_areas
+</pre></div>
+
+
+<h2>SEE ALSO</h2><em>
+<a href="http://www4.ncsu.edu/~ejhardi2/v.generalize.html">v.generalize</a>, 
+<a href="http://www4.ncsu.edu/~ejhardi2/r.transect.html">r.transect</A> </em>
+
+
+<h2>AUTHOR</h2>Eric Hardin, Helena Mitasova, Updates by John Lloyd 
+<p>
+<i>Last changed: $Date$</i>

Modified: grass-addons/grass7/vector/v.transects/v.transects.py
===================================================================
--- grass-addons/grass6/vector/v.transects/v.transects.py	2013-10-15 23:19:37 UTC (rev 58010)
+++ grass-addons/grass7/vector/v.transects/v.transects.py	2013-10-25 17:27:00 UTC (rev 58106)
@@ -5,59 +5,47 @@
 # MODULE:      v.transects.py
 # AUTHOR(S):   Eric Hardin
 # PURPOSE:     Creates lines or quadrilateral areas perpendicular to a polyline
-# COPYRIGHT:   (C) 2011
+# COPYRIGHT:   (C) 2013
 #
 #              This program is free software under the GNU General Public
 #              License (>=v2). Read the file COPYING that comes with GRASS
 #              for details.
-# 
+#
 # UPDATES:     John Lloyd November 2011
+#              Anna Petrasova 2013 (update for GRASS 7)
 #
 #############################################################################
-#%Module
+#%module
 #% description: Creates transect lines or quadrilateral areas at regular intervals perpendicular to a polyline.
-#%End
-#%option
-#% key: input
-#% type: string
-#% description: Name of input vector map
-#% gisprompt: old,vector,vector
-#% required : yes
 #%end
-#%option
-#% key: output
-#% type: string
-#% description: Name of output vector map
-#% gisprompt: new,vector,vector
-#% required : yes
+#%option G_OPT_V_INPUT
 #%end
+#%option G_OPT_V_OUTPUT
+#%end
 #%option
 #% key: transect_spacing
 #% type: double
 #% description: Transect spacing along input polyline
-#% required : yes
+#% required: yes
 #%end
 #%option
 #% key: dleft
 #% type: double
 #% label: Distance transect extends to the left of input line
 #% description: Default is the same as the transect spacing
-#% required : no
+#% required: no
 #%end
 #%option
 #% key: dright
 #% type: double
 #% label: Distance transect extends to the right of input line
 #% description: Default is the same as the transect spacing
-#% required : no
+#% required: no
 #%end
-#%option
-#% key: type
-#% type: string
-#% description: Feature type
-#% required : no
-#% options: line,area,point
-#% answer : line
+#%option G_OPT_V_TYPE
+#% multiple: no
+#% options: point,line,area
+#% answer: line
 #%end
 
 from subprocess import Popen, PIPE, STDOUT
@@ -65,32 +53,38 @@
 from math import sqrt
 import grass.script as grass
 import tempfile
-####################################
-# Returns the name of a vector map not in the current mapset.
-# mapname is of the form temp_xxxxxx where xxxxxx is a random number
+import random
+
+
 def tempmap():
-    import random
-    rand_number = [ random.randint(0,9) for i in range(6) ]
-    rand_number_str = ''.join( map(str,rand_number) )
+    """!Returns the name of a vector map not in the current mapset.
+
+    Mapname is of the form temp_xxxxxx where xxxxxx is a random number.
+    """
+    rand_number = [random.randint(0, 9) for i in range(6)]
+    rand_number_str = ''.join(map(str, rand_number))
     mapname = 'temp_' + rand_number_str
-    maplist = grass.read_command('g.list',type='vect',mapset='.').split()
+    maplist = grass.read_command('g.list', type='vect', mapset='.').split()
     while mapname in maplist:
-        rand_number = [ random.randint(0,9) for i in range(6) ]
-        rand_number_str = ''.join( map(str,rand_number) )
+        rand_number = [random.randint(0, 9) for i in range(6)]
+        rand_number_str = ''.join(map(str, rand_number))
         mapname = 'temp_' + rand_number_str
-        maplist = grass.read_command('g.list',type='vect',mapset='.').split()
+        maplist = grass.read_command('g.list', type='vect', mapset='.').split()
     return mapname
 
-####################################
-# load vector lines into python list
-# returns v
-# len(v) = number of lines in vector map
-# len(v[i]) = number of vertices in ith line 
-# v[i][j] = [ xij, yij ] ,i.e., jth vertex in ith line
-def loadVector( vector ):
-    expVecCmmd = 'v.out.ascii format=standard input='+vector
+
+def loadVector(vector):
+    """!Load vector lines into python list.
+
+    Returns v:
+    len(v) = number of lines in vector map
+    len(v[i]) = number of vertices in ith line
+    v[i][j] = [ xij, yij ] ,i.e., jth vertex in ith line
+    """
+    expVecCmmd = 'v.out.ascii format=standard input=' + vector
 # JL    p = Popen(expVecCmmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
-    p = Popen(expVecCmmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=False)
+    p = Popen(expVecCmmd, shell=True, stdin=PIPE, stdout=PIPE,
+              stderr=STDOUT, close_fds=False)
     vectorAscii = p.stdout.read().strip('\n').split('\n')
     l = 0
     while 'ORGANIZATION' not in vectorAscii[l]:
@@ -100,17 +94,17 @@
     v = []
     while l < len(vectorAscii):
         line = vectorAscii[l].split()
-        if line[0] in ['L','B','A']:
-            skip = len(line)-2
+        if line[0] in ['L', 'B', 'A']:
+            skip = len(line) - 2
             vertices = int(line[1])
             l += 1
             v.append([])
             for i in range(vertices):
-                v[-1].append( map(float,vectorAscii[l].split()[:2]) )
+                v[-1].append(map(float, vectorAscii[l].split()[:2]))
                 l += 1
             l += skip
-        elif line[0] in ['P','C','F','K']:
-            skip = len(line)-2
+        elif line[0] in ['P', 'C', 'F', 'K']:
+            skip = len(line) - 2
             vertices = int(line[1])
             l += 1
             for i in range(vertices):
@@ -122,114 +116,124 @@
         grass.fatal(_("Zero lines found in vector map <%s>") % vector)
     return v
 
-####################################
-# get transects locations along input vector lines
-def get_transects_locs( vector, transect_spacing ): 
-    transect_locs = [] # holds locations where transects should intersect input vector lines
-    for line in vector:    
+
+def get_transects_locs(vector, transect_spacing):
+    """!Get transects locations along input vector lines."""
+    # holds locations where transects should intersect input vector lines
+    transect_locs = []
+    for line in vector:
         transect_locs.append([line[0]])
         # i starts at the beginning of the line.
         # j walks along the line until j and i are separated by a distance of transect_spacing.
         # then, a transect is placed at j, i is moved to j, and this is iterated until the end of the line is reached
         i = 0
-        j = i+1
+        j = i + 1
         while j < len(line):
-            d = dist( line[i],line[j] )
+            d = dist(line[i], line[j])
             if d > transect_spacing:
-                r = (transect_spacing - dist(line[i],line[j-1]) )/( dist(line[i],line[j]) - dist(line[i],line[j-1]) )
-                transect_locs[-1].append(  (r*array( line[j] ) + (1-r)*array( line[j-1] )).tolist()  )
-                i = j-1
+                r = ((transect_spacing - dist(line[i], line[j - 1])) /
+                    (dist(line[i], line[j]) - dist(line[i], line[j - 1])))
+                transect_locs[-1].append((r * array(line[j]) +
+                                         (1 - r) * array(line[j - 1])).tolist())
+                i = j - 1
                 line[i] = transect_locs[-1][-1]
             else:
                 j += 1
     return transect_locs
 
-####################################
-# from transects locations along input vector lines, get transect ends
-def get_transect_ends( transect_locs, dleft, dright ):
+
+def get_transect_ends(transect_locs, dleft, dright):
+    """!From transects locations along input vector lines, get transect ends."""
     transect_ends = []
     for transect in transect_locs:
-        if len(transect) < 2: # if a line in input vec was shorter than transect_spacing
-            continue # then don't put a transect on it
+        # if a line in input vec was shorter than transect_spacing
+        if len(transect) < 2:
+            continue  # then don't put a transect on it
         transect_ends.append([])
-        transect = array( transect )
-        v = NR( transect[0], transect[1] ) # vector pointing parallel to transect
-        transect_ends[-1].append( [ transect[0]+dleft*v, transect[0]-dright*v ] )
-        for i in range(1,len( transect )-1,1):
-            v = NR( transect[i-1], transect[i+1] )
-            transect_ends[-1].append( [ transect[i]+dleft*v, transect[i]-dright*v ] )
-        v = NR( transect[-2], transect[-1] )
-        transect_ends[-1].append( [ transect[-1]+dleft*v, transect[-1]-dright*v ] )
+        transect = array(transect)
+        v = NR(transect[0], transect[1])  # vector pointing parallel to transect
+        transect_ends[-1].append([transect[0] + dleft * v, transect[0] - dright * v])
+        for i in range(1, len(transect) - 1, 1):
+            v = NR(transect[i - 1], transect[i + 1])
+            transect_ends[-1].append([transect[i] + dleft * v, transect[i] - dright * v])
+        v = NR(transect[-2], transect[-1])
+        transect_ends[-1].append([transect[-1] + dleft * v, transect[-1] - dright * v])
     return transect_ends
 
-####################################
-# calculate distance between two points
-def dist( ip, fp ): 
-    return sqrt( (ip[0]-fp[0])**2 + (ip[1]-fp[1])**2 )
 
-####################################
-# take a vector, normalize and rotate it 90 degrees
-def NR( ip, fp ): 
+def dist(ip, fp):
+    """!Calculates distance between two points"""
+    return sqrt((ip[0] - fp[0]) ** 2 + (ip[1] - fp[1]) ** 2)
+
+
+def NR(ip, fp):
+    """!Take a vector, normalize and rotate it 90 degrees."""
     x = fp[0] - ip[0]
     y = fp[1] - ip[1]
-    r = sqrt( x**2 + y**2 )
-    return array([ -y/r, x/r ])
+    r = sqrt(x ** 2 + y ** 2)
+    return array([-y / r, x / r])
 
-####################################
-# write transects
-def writeTransects( transects, output ):
+
+def writeTransects(transects, output):
+    """!Writes transects."""
     transects_str = ''
     for transect in transects:
-        transects_str += '\n'.join( [ 'L 2\n'+' '.join(map(str,end_points[0]))+'\n'+' '.join(map(str,end_points[1]))+'\n' for end_points in transect ] )
+        transects_str += '\n'.join(['L 2\n' + ' '.join(map(str, end_points[0])) + '\n' +
+                                    ' '.join(map(str, end_points[1])) +
+                                    '\n' for end_points in transect])
     # JL Rewrote Temporary File Logic for Windows
     _, temp_path = tempfile.mkstemp()
     a = open(temp_path, 'w')
-    a.write( transects_str )
+    a.write(transects_str)
     a.seek(0)
     a.close()
-    grass.run_command('v.in.ascii', flags='n', input=temp_path, output=output, format='standard')
-    
+    grass.run_command('v.in.ascii', flags='n', input=temp_path, output=output,
+                      format='standard')
 
-####################################
-# writes areas 
-def writeQuads( transects, output ):
+
+def writeQuads(transects, output):
+    """!Writes areas."""
     quad_str = ''
     cnt = 1
     for line in transects:
-        for tran in range( len(line)-1 ):
-            pt1 = ' '.join( map(str,line[tran][0]) )
-            pt2 = ' '.join( map(str,line[tran][1]) )
-            pt3 = ' '.join( map(str,line[tran+1][1]) )
-            pt4 = ' '.join( map(str,line[tran+1][0]) )
+        for tran in range(len(line) - 1):
+            pt1 = ' '.join(map(str, line[tran][0]))
+            pt2 = ' '.join(map(str, line[tran][1]))
+            pt3 = ' '.join(map(str, line[tran + 1][1]))
+            pt4 = ' '.join(map(str, line[tran + 1][0]))
             pt5 = pt1
             # centroid is the average of the four corners
-            c = ' '.join( map(str,[ 0.25*(line[tran][0][0]+line[tran][1][0]+line[tran+1][0][0]+line[tran+1][1][0]), 0.25*(line[tran][0][1]+line[tran][1][1]+line[tran+1][0][1]+line[tran+1][1][1]) ]) )
-            quad_str += 'B 5\n' + '\n'.join([pt1,pt2,pt3,pt4,pt5]) + '\n'
+            c = ' '.join(map(str, [0.25 * (line[tran][0][0] + line[tran][1][0] +
+                                           line[tran + 1][0][0] + line[tran + 1][1][0]),
+                                   0.25 * (line[tran][0][1] + line[tran][1][1] +
+                                           line[tran + 1][0][1] + line[tran + 1][1][1])]))
+            quad_str += 'B 5\n' + '\n'.join([pt1, pt2, pt3, pt4, pt5]) + '\n'
             quad_str += 'C 1 1\n' + c + '\n1 ' + str(cnt) + '\n'
             cnt += 1
     # JL Rewrote Temporary File Logic for Windows
     _, temp_path = tempfile.mkstemp()
     a = open(temp_path, 'w')
-    a.write( quad_str )
+    a.write(quad_str)
     a.seek(0)
     a.close()
-    grass.run_command('v.in.ascii', flags='n', input=a.name, output=output, format='standard')
+    grass.run_command('v.in.ascii', flags='n', input=a.name,
+                      output=output, format='standard')
 
-####################################
-# writes areas 
-def writePoints( transect_locs, output ):
+
+def writePoints(transect_locs, output):
+    """!Writes points."""
     pt_str = ''
     for pts in transect_locs:
-        pt_str += '\n'.join( [ ','.join(map(str,pt)) for pt in pts ] ) + '\n'
+        pt_str += '\n'.join([','.join(map(str, pt)) for pt in pts]) + '\n'
     _, temp_path = tempfile.mkstemp()
     a = open(temp_path, 'w')
-    a.write( pt_str )
+    a.write(pt_str)
     a.seek(0)
     a.close()
-    grass.run_command('v.in.ascii', input=a.name, output=output, format='point', fs=',', x=1, y=2)
+    grass.run_command('v.in.ascii', input=a.name, output=output,
+                      format='point', separator=',', x=1, y=2)
 
-####################################
-# Main method
+
 def main():
     vector = options['input']
     output = options['output']
@@ -243,8 +247,8 @@
     dleft = options['dleft']
     dright = options['dright']
     shape = options['type']
-    print dleft, transect_spacing
-    if not dleft: 
+
+    if not dleft:
         dleft = transect_spacing
     else:
         # JL Handling Invalid dleft parameter
@@ -252,7 +256,7 @@
             dleft = float(dleft)
         except:
             grass.fatal(_("Invalid dleft value."))
-    if not dright: 
+    if not dright:
         dright = transect_spacing
     else:
         # JL Handling Invalid dright parameter
@@ -261,36 +265,35 @@
         except:
             grass.fatal(_("Invalid dright value."))
     # check if input file does not exists
-    if not grass.find_file(vector, element='vector')['file']: 
+    if not grass.find_file(vector, element='vector')['file']:
         grass.fatal(_("<%s> does not exist.") % vector)
     # check if output file exists
-    if grass.find_file(output, element='vector')['mapset'] == grass.gisenv()['MAPSET']: 
+    if grass.find_file(output, element='vector')['mapset'] == grass.gisenv()['MAPSET']:
         if not grass.overwrite():
             grass.fatal(_("output map <%s> exists") % output)
 
     #JL Is the vector a line and does if have at least one feature?
-    info = grass.parse_command('v.info', flags = 't', map = vector)
+    info = grass.parse_command('v.info', flags='t', map=vector)
     if info['lines'] == '0':
-         grass.fatal(_("vector <%s> does not contain lines") % vector)
+        grass.fatal(_("vector <%s> does not contain lines") % vector)
 
     #################################
-    v = loadVector( vector )
-    transect_locs = get_transects_locs( v, transect_spacing )
+    v = loadVector(vector)
+    transect_locs = get_transects_locs(v, transect_spacing)
     temp_map = tempmap()
-    if shape == 'line' or not shape: 
-        transect_ends = get_transect_ends( transect_locs, dleft, dright )
-        writeTransects( transect_ends, temp_map )
+    if shape == 'line' or not shape:
+        transect_ends = get_transect_ends(transect_locs, dleft, dright)
+        writeTransects(transect_ends, temp_map)
     elif shape == 'area':
-        transect_ends = get_transect_ends( transect_locs, dleft, dright )
-        writeQuads( transect_ends, temp_map )
+        transect_ends = get_transect_ends(transect_locs, dleft, dright)
+        writeQuads(transect_ends, temp_map)
     else:
-        writePoints( transect_locs, temp_map )
- 
-    grass.run_command( 'v.category', input=temp_map, output=output, type=shape )
-    grass.run_command( 'g.remove', vect=temp_map )
+        writePoints(transect_locs, temp_map)
 
+    grass.run_command('v.category', input=temp_map, output=output,
+                      option='add', type=shape)
+    grass.run_command('g.remove', vect=temp_map)
+
 if __name__ == "__main__":
-   options, flags = grass.parser()
-   main()
-
-
+    options, flags = grass.parser()
+    main()



More information about the grass-commit mailing list