[GRASS-SVN] r32857 - in grass/trunk: include/Make
scripts/d.shadedmap scripts/r.in.aster scripts/r.out.xyz
scripts/v.build.all scripts/v.centroids scripts/v.convert.all
scripts/v.in.sites.all scripts/v.what.vect
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 18 11:58:53 EDT 2008
Author: glynn
Date: 2008-08-18 11:58:53 -0400 (Mon, 18 Aug 2008)
New Revision: 32857
Added:
grass/trunk/scripts/d.shadedmap/d.shadedmap.py
grass/trunk/scripts/r.in.aster/r.in.aster.py
grass/trunk/scripts/r.out.xyz/r.out.xyz.py
grass/trunk/scripts/v.build.all/v.build.all.py
grass/trunk/scripts/v.centroids/v.centroids.py
grass/trunk/scripts/v.convert.all/v.convert.all.py
grass/trunk/scripts/v.in.sites.all/v.in.sites.all.py
grass/trunk/scripts/v.what.vect/v.what.vect.py
Removed:
grass/trunk/scripts/r.in.aster/r_in_aster.py
Modified:
grass/trunk/include/Make/Script.make
Log:
Add Python versions of various scripts
Change Script.make to prefer Python versions over Bourne shell versions
Modified: grass/trunk/include/Make/Script.make
===================================================================
--- grass/trunk/include/Make/Script.make 2008-08-18 15:57:30 UTC (rev 32856)
+++ grass/trunk/include/Make/Script.make 2008-08-18 15:58:53 UTC (rev 32857)
@@ -17,11 +17,16 @@
script: $(SCRIPT_ACTIONS)
-$(SCRIPT): $(PGM)
+$(SCRIPTDIR)/%: %.py
if [ ! -d $(SCRIPTDIR) ]; then $(MKDIR) $(SCRIPTDIR); fi
- $(INSTALL) $(PGM) $(SCRIPT)
+ $(INSTALL) $< $@
$(MAKE) htmlscript scriptstrings
+$(SCRIPTDIR)/%: %
+ if [ ! -d $(SCRIPTDIR) ]; then $(MKDIR) $(SCRIPTDIR); fi
+ $(INSTALL) $< $@
+ $(MAKE) htmlscript scriptstrings
+
$(BIN)/$(PGM).bat: $(MODULE_TOPDIR)/scripts/windows_launch.bat
sed -e "s#SCRIPT_NAME#$(PGM)#" $(MODULE_TOPDIR)/scripts/windows_launch.bat > $@
Added: grass/trunk/scripts/d.shadedmap/d.shadedmap.py
===================================================================
--- grass/trunk/scripts/d.shadedmap/d.shadedmap.py (rev 0)
+++ grass/trunk/scripts/d.shadedmap/d.shadedmap.py 2008-08-18 15:58:53 UTC (rev 32857)
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+#
+############################################################################
+#
+# MODULE: d.shadedmap
+# AUTHOR(S): Unknown; updated to GRASS 5.7 by Michael Barton
+# Converted to Python by Glynn Clements
+# PURPOSE: Uses d.his to drape a color raster over a shaded relief map
+# COPYRIGHT: (C) 2004,2008 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%Module
+#% description: Drapes a color raster over a shaded relief map using d.his
+#%End
+#%option
+#% key: reliefmap
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Name of shaded relief or aspect map
+#% required : yes
+#%end
+#%option
+#% key: drapemap
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Name of raster to drape over relief map
+#% required : yes
+#%end
+#%option
+#% key: brighten
+#% type: integer
+#% description: Percent to brighten
+#% options: -99-99
+#% answer: 0
+#%end
+
+import sys
+import grass
+
+def main():
+ drape_map = options['drapemap']
+ relief_map = options['reliefmap']
+ brighten = options['brighten']
+ ret = grass.run_command("d.his", h_map = drapemap, i_map = relief_map, brighten = brighten)
+ sys.exit(ret)
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
Property changes on: grass/trunk/scripts/d.shadedmap/d.shadedmap.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Copied: grass/trunk/scripts/r.in.aster/r.in.aster.py (from rev 32853, grass/trunk/scripts/r.in.aster/r_in_aster.py)
===================================================================
--- grass/trunk/scripts/r.in.aster/r.in.aster.py (rev 0)
+++ grass/trunk/scripts/r.in.aster/r.in.aster.py 2008-08-18 15:58:53 UTC (rev 32857)
@@ -0,0 +1,203 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE: r_in_aster.py
+# AUTHOR(S): Michael Barton (michael.barton at asu.edu) and
+# Glynn Clements (glynn at gclements.plus.com)
+# Based on r.in.aster bash script for GRASS
+# by Michael Barton and Paul Kelly
+# PURPOSE: Rectifies, georeferences, & imports Terra-ASTER imagery
+# using gdalwarp
+# COPYRIGHT: (C) 2008 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+#
+# Requires:
+# gdalwarp
+# gdal compiled with HDF4 support
+
+#%Module
+#% description: Georeference, rectify, and import Terra-ASTER imagery and relative DEM's using gdalwarp.
+#% keywords: raster, imagery, import
+#%End
+#%option
+#% key: input
+#% type: string
+#% gisprompt: old_file,file,input
+#% description: Input ASTER image to be georeferenced & rectified
+#% required: yes
+#%end
+#%option
+#% key: proctype
+#% type: string
+#% description: ASTER imagery processing type (Level 1A, Level 1B, or relative DEM)
+#% options: L1A,L1B,DEM
+#% answer: L1B
+#% required: yes
+#%end
+#%option
+#% key: band
+#% type: string
+#% description: List L1A or L1B band to translate (1,2,3n,...), or enter 'all' to translate all bands
+#% answer: all
+#% required: yes
+#%end
+#%option
+#% key: output
+#% type: string
+#% description: Base name for output raster map (band number will be appended to base name)
+#% gisprompt: old,cell,raster
+#% required: yes
+#%end
+#%flag
+#% key: o
+#% description: Overwrite existing file
+#%END
+
+import sys
+import os
+import subprocess
+import platform
+import grass
+
+bands = {
+ 'L1A': {
+ '1': "VNIR_Band1:ImageData",
+ '2': "VNIR_Band2:ImageData",
+ '3n': "VNIR_Band3N:ImageData",
+ '3b': "VNIR_Band3B:ImageData",
+ '4': "SWIR_Band4:ImageData",
+ '5': "SWIR_Band5:ImageData",
+ '6': "SWIR_Band6:ImageData",
+ '7': "SWIR_Band7:ImageData",
+ '8': "SWIR_Band8:ImageData",
+ '9': "SWIR_Band9:ImageData",
+ '10': "TIR_Band10:ImageData",
+ '11': "TIR_Band11:ImageData",
+ '12': "TIR_Band12:ImageData",
+ '13': "TIR_Band13:ImageData",
+ '14': "TIR_Band14:ImageData"
+ },
+ 'L1B': {
+ '1': "VNIR_Swath:ImageData1",
+ '2': "VNIR_Swath:ImageData2",
+ '3n': "VNIR_Swath:ImageData3N",
+ '3b': "VNIR_Swath:ImageData3B",
+ '4': "SWIR_Swath:ImageData4",
+ '5': "SWIR_Swath:ImageData5",
+ '6': "SWIR_Swath:ImageData6",
+ '7': "SWIR_Swath:ImageData7",
+ '8': "SWIR_Swath:ImageData8",
+ '9': "SWIR_Swath:ImageData9",
+ '10': "TIR_Swath:ImageData10",
+ '11': "TIR_Swath:ImageData11",
+ '12': "TIR_Swath:ImageData12",
+ '13': "TIR_Swath:ImageData13",
+ '14': "TIR_Swath:ImageData14"
+ }
+}
+
+def _message(msg, *args):
+ subprocess.call(["g.message", "message=%s" % msg] + list(args))
+
+def debug(msg):
+ _message(msg, '-d')
+
+def message(msg):
+ _message(msg)
+
+def error(msg):
+ _message(msg, '-e')
+ sys.exit(1)
+
+def main():
+
+ #check whether gdalwarp is in path and executable
+ p = None
+ try:
+ p = subprocess.call(['gdalwarp', '--version'])
+ except:
+ pass
+ if p == None or p != 0:
+ error("gdalwarp is not in the path and executable")
+
+ #initialize variables
+ dataset = ''
+ srcfile = ''
+ proj = ''
+ band = ''
+ outfile = ''
+ bandlist = []
+
+ #create temporary file to hold gdalwarp output before importing to GRASS
+ tempfile = grass.read_command("g.tempfile", pid = os.getpid()).strip() + '.tif'
+
+ #get projection information for current GRASS location
+ proj = grass.read_command('g.proj', flags = 'jf').strip()
+
+ #currently only runs in projected location
+ if "XY location" in proj:
+ error ("This module needs to be run in a projected location (found: %s)" % proj)
+
+
+ #process list of bands
+ allbands = ['1','2','3n','3b','4','5','6','7','8','9','10','11','12','13','14']
+ if options['band'].strip() == 'all':
+ bandlist = allbands
+ else:
+ bandlist = options['band'].split(',')
+
+ #initialize datasets for L1A and L1B
+ if options['proctype'] in ["L1A", "L1B"]:
+ for band in bandlist:
+ if band in allbands:
+ dataset = bands[options['proctype']][band]
+ srcfile = "HDF4_EOS:EOS_SWATH:%s:%s" % (options['input'], dataset)
+ import_aster(proj, srcfile, tempfile, band)
+ else:
+ error('band %s is not an available Terra/ASTER band' % band)
+ elif options['proctype'] == "DEM":
+ srcfile=options['input']
+ import_aster(proj, srcfile, tempfile, "DEM")
+
+ # write cmd history: Not sure how to replicate this in Python yet
+ #r.support "$GIS_OPT_OUTPUT" history="${CMDLINE}"
+
+ #cleanup
+ message("Cleaning up ...")
+ os.remove(tempfile)
+ message("Done.")
+
+ return
+
+def import_aster(proj, srcfile, tempfile, band):
+ #run gdalwarp with selected options (must be in $PATH)
+ #to translate aster image to geotiff
+ message("Georeferencing aster image ...")
+ debug("gdalwarp -t_srs %s %s %s" % (proj, srcfile, tempfile))
+
+ if platform.system() == "Darwin":
+ cmd = ["arch", "-i386", "gdalwarp", "-t_srs", proj, srcfile, tempfile ]
+ else:
+ cmd = ["gdalwarp", "-t_srs", proj, srcfile, tempfile ]
+ p = subprocess.call(cmd)
+ if p != 0:
+ #check to see if gdalwarp executed properly
+ return
+
+ #p = subprocess.call(["gdal_translate", srcfile, tempfile])
+
+ #import geotiff to GRASS
+ message("Importing into GRASS ...")
+ outfile = options['output'].strip()+'.'+band
+ grass.run_command("r.in.gdal", overwrite = flags['o'], input = tempfile, output = outfile)
+
+ return
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
Property changes on: grass/trunk/scripts/r.in.aster/r.in.aster.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Deleted: grass/trunk/scripts/r.in.aster/r_in_aster.py
===================================================================
--- grass/trunk/scripts/r.in.aster/r_in_aster.py 2008-08-18 15:57:30 UTC (rev 32856)
+++ grass/trunk/scripts/r.in.aster/r_in_aster.py 2008-08-18 15:58:53 UTC (rev 32857)
@@ -1,203 +0,0 @@
-#!/usr/bin/python
-############################################################################
-#
-# MODULE: r_in_aster.py
-# AUTHOR(S): Michael Barton (michael.barton at asu.edu) and
-# Glynn Clements (glynn at gclements.plus.com)
-# Based on r.in.aster bash script for GRASS
-# by Michael Barton and Paul Kelly
-# PURPOSE: Rectifies, georeferences, & imports Terra-ASTER imagery
-# using gdalwarp
-# COPYRIGHT: (C) 2008 by the GRASS Development Team
-#
-# This program is free software under the GNU General Public
-# License (>=v2). Read the file COPYING that comes with GRASS
-# for details.
-#
-#############################################################################
-#
-# Requires:
-# gdalwarp
-# gdal compiled with HDF4 support
-
-#%Module
-#% description: Georeference, rectify, and import Terra-ASTER imagery and relative DEM's using gdalwarp.
-#% keywords: raster, imagery, import
-#%End
-#%option
-#% key: input
-#% type: string
-#% gisprompt: old_file,file,input
-#% description: Input ASTER image to be georeferenced & rectified
-#% required: yes
-#%end
-#%option
-#% key: proctype
-#% type: string
-#% description: ASTER imagery processing type (Level 1A, Level 1B, or relative DEM)
-#% options: L1A,L1B,DEM
-#% answer: L1B
-#% required: yes
-#%end
-#%option
-#% key: band
-#% type: string
-#% description: List L1A or L1B band to translate (1,2,3n,...), or enter 'all' to translate all bands
-#% answer: all
-#% required: yes
-#%end
-#%option
-#% key: output
-#% type: string
-#% description: Base name for output raster map (band number will be appended to base name)
-#% gisprompt: old,cell,raster
-#% required: yes
-#%end
-#%flag
-#% key: o
-#% description: Overwrite existing file
-#%END
-
-import sys
-import os
-import subprocess
-import platform
-import grass
-
-bands = {
- 'L1A': {
- '1': "VNIR_Band1:ImageData",
- '2': "VNIR_Band2:ImageData",
- '3n': "VNIR_Band3N:ImageData",
- '3b': "VNIR_Band3B:ImageData",
- '4': "SWIR_Band4:ImageData",
- '5': "SWIR_Band5:ImageData",
- '6': "SWIR_Band6:ImageData",
- '7': "SWIR_Band7:ImageData",
- '8': "SWIR_Band8:ImageData",
- '9': "SWIR_Band9:ImageData",
- '10': "TIR_Band10:ImageData",
- '11': "TIR_Band11:ImageData",
- '12': "TIR_Band12:ImageData",
- '13': "TIR_Band13:ImageData",
- '14': "TIR_Band14:ImageData"
- },
- 'L1B': {
- '1': "VNIR_Swath:ImageData1",
- '2': "VNIR_Swath:ImageData2",
- '3n': "VNIR_Swath:ImageData3N",
- '3b': "VNIR_Swath:ImageData3B",
- '4': "SWIR_Swath:ImageData4",
- '5': "SWIR_Swath:ImageData5",
- '6': "SWIR_Swath:ImageData6",
- '7': "SWIR_Swath:ImageData7",
- '8': "SWIR_Swath:ImageData8",
- '9': "SWIR_Swath:ImageData9",
- '10': "TIR_Swath:ImageData10",
- '11': "TIR_Swath:ImageData11",
- '12': "TIR_Swath:ImageData12",
- '13': "TIR_Swath:ImageData13",
- '14': "TIR_Swath:ImageData14"
- }
-}
-
-def _message(msg, *args):
- subprocess.call(["g.message", "message=%s" % msg] + list(args))
-
-def debug(msg):
- _message(msg, '-d')
-
-def message(msg):
- _message(msg)
-
-def error(msg):
- _message(msg, '-e')
- sys.exit(1)
-
-def main():
-
- #check whether gdalwarp is in path and executable
- p = None
- try:
- p = subprocess.call(['gdalwarp', '--version'])
- except:
- pass
- if p == None or p != 0:
- error("gdalwarp is not in the path and executable")
-
- #initialize variables
- dataset = ''
- srcfile = ''
- proj = ''
- band = ''
- outfile = ''
- bandlist = []
-
- #create temporary file to hold gdalwarp output before importing to GRASS
- tempfile = grass.read_command("g.tempfile", pid = os.getpid()).strip() + '.tif'
-
- #get projection information for current GRASS location
- proj = grass.read_command('g.proj', flags = 'jf').strip()
-
- #currently only runs in projected location
- if "XY location" in proj:
- error ("This module needs to be run in a projected location (found: %s)" % proj)
-
-
- #process list of bands
- allbands = ['1','2','3n','3b','4','5','6','7','8','9','10','11','12','13','14']
- if options['band'].strip() == 'all':
- bandlist = allbands
- else:
- bandlist = options['band'].split(',')
-
- #initialize datasets for L1A and L1B
- if options['proctype'] in ["L1A", "L1B"]:
- for band in bandlist:
- if band in allbands:
- dataset = bands[options['proctype']][band]
- srcfile = "HDF4_EOS:EOS_SWATH:%s:%s" % (options['input'], dataset)
- import_aster(proj, srcfile, tempfile, band)
- else:
- error('band %s is not an available Terra/ASTER band' % band)
- elif options['proctype'] == "DEM":
- srcfile=options['input']
- import_aster(proj, srcfile, tempfile, "DEM")
-
- # write cmd history: Not sure how to replicate this in Python yet
- #r.support "$GIS_OPT_OUTPUT" history="${CMDLINE}"
-
- #cleanup
- message("Cleaning up ...")
- os.remove(tempfile)
- message("Done.")
-
- return
-
-def import_aster(proj, srcfile, tempfile, band):
- #run gdalwarp with selected options (must be in $PATH)
- #to translate aster image to geotiff
- message("Georeferencing aster image ...")
- debug("gdalwarp -t_srs %s %s %s" % (proj, srcfile, tempfile))
-
- if platform.system() == "Darwin":
- cmd = ["arch", "-i386", "gdalwarp", "-t_srs", proj, srcfile, tempfile ]
- else:
- cmd = ["gdalwarp", "-t_srs", proj, srcfile, tempfile ]
- p = subprocess.call(cmd)
- if p != 0:
- #check to see if gdalwarp executed properly
- return
-
- #p = subprocess.call(["gdal_translate", srcfile, tempfile])
-
- #import geotiff to GRASS
- message("Importing into GRASS ...")
- outfile = options['output'].strip()+'.'+band
- grass.run_command("r.in.gdal", overwrite = flags['o'], input = tempfile, output = outfile)
-
- return
-
-if __name__ == "__main__":
- options, flags = grass.parser()
- main()
Added: grass/trunk/scripts/r.out.xyz/r.out.xyz.py
===================================================================
--- grass/trunk/scripts/r.out.xyz/r.out.xyz.py (rev 0)
+++ grass/trunk/scripts/r.out.xyz/r.out.xyz.py 2008-08-18 15:58:53 UTC (rev 32857)
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE: r.out.xyz
+# AUTHOR: M. Hamish Bowman, Dept. Marine Science, Otago Univeristy,
+# New Zealand
+# Converted to Python by Glynn Clements
+# PURPOSE: Export a raster map as x,y,z values based on cell centers
+# This is a simple wrapper script for "r.stats -1ng"
+#
+# COPYRIGHT: (c) 2006 Hamish Bowman, and the GRASS Development Team
+# (c) 2008 Glynn Clements, and the GRASS Development Team
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%Module
+#% description: Export a raster map to a text file as x,y,z values based on cell centers.
+#% keywords: raster, export
+#%End
+#%option
+#% key: input
+#% type: string
+#% gisprompt: old,cell,raster
+#% key_desc: name
+#% description: Name of input raster map
+#% required: yes
+#%end
+#%option
+#% key: output
+#% type: string
+#% gisprompt: new_file,file,output
+#% key_desc: name
+#% description: Name for output file (if omitted or "-" output to stdout)
+#% required: no
+#%end
+#%option
+#% key: fs
+#% type: string
+#% key_desc: character
+#% description: Field separator
+#% answer: |
+#% required: no
+#%end
+
+import sys
+import grass
+
+def main():
+ # if no output filename, output to stdout
+ output = options['output']
+ if output == "" or output == "-":
+ outf = sys.stdout
+ else:
+ outf = file(output)
+ ret = grass.run_command("r.stats", flags = "1gn", input = options['input'], fs = options['fs'], stdout = outf)
+ sys.exit(ret)
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
Property changes on: grass/trunk/scripts/r.out.xyz/r.out.xyz.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Added: grass/trunk/scripts/v.build.all/v.build.all.py
===================================================================
--- grass/trunk/scripts/v.build.all/v.build.all.py (rev 0)
+++ grass/trunk/scripts/v.build.all/v.build.all.py 2008-08-18 15:58:53 UTC (rev 32857)
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE: v.build.all
+# AUTHOR(S): Glynn Clements, Radim Blazek
+# PURPOSE: Build all vectors in current mapset
+# COPYRIGHT: (C) 2004,2008 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%Module
+#% description: Rebuilds topology on all vector maps in the current mapset.
+#% keywords: vector
+#%End
+
+import sys
+import grass
+
+def main():
+ env = grass.gisenv()
+ mapset = env['MAPSET']
+ ret = 0
+ for vect in grass.list_grouped('vect')[mapset]:
+ map = "%s@%s" % (vect, mapset)
+ grass.message("Build topology for vector '%s'" % map)
+ grass.message("v.build map=%s" % map)
+ if grass.run_command("v.build", map = map) != 0:
+ ret = 1
+ sys.exit(ret)
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
Property changes on: grass/trunk/scripts/v.build.all/v.build.all.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Added: grass/trunk/scripts/v.centroids/v.centroids.py
===================================================================
--- grass/trunk/scripts/v.centroids/v.centroids.py (rev 0)
+++ grass/trunk/scripts/v.centroids/v.centroids.py 2008-08-18 15:58:53 UTC (rev 32857)
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE: v.centroids
+# AUTHOR: Hamish Bowman
+# PURPOSE: Add missing centroids (frontend to v.category opt=add)
+# COPYRIGHT: (c) 2006 Hamish Bowman, and the GRASS Development Team
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%Module
+#% description: Adds missing centroids to closed boundaries.
+#% keywords: vector, centroid, area
+#%End
+
+#%option
+#% key: input
+#% type: string
+#% gisprompt: old,vector,vector
+#% key_desc: name
+#% description: Name of input vector map
+#%required: yes
+#%end
+
+#%option
+#% key: output
+#% type: string
+#% gisprompt: new,vector,vector
+#% key_desc: name
+#% description: Name for output vector map
+#% required: yes
+#%end
+
+#%option
+#% key: option
+#% type: string
+#% description: Action to be taken
+#% options: add
+#% answer: add
+#% required: no
+#%end
+
+#%option
+#% key: layer
+#% type: integer
+#% description: Layer number
+#% answer: 1
+#% required: no
+#%end
+
+#%option
+#% key: cat
+#% type: integer
+#% description: Category number starting value
+#% answer: 1
+#% required: no
+#%end
+
+#%option
+#% key: step
+#% type: integer
+#% description: Category increment
+#% answer: 1
+#% required: no
+#%end
+
+import sys
+import os
+import re
+import grass
+
+def main():
+ if options['option'] == 'add':
+ num_bound = 0
+ tenv = os.environ.copy()
+ tenv['LC_ALL'] = 'C'
+ lines = grass.read_command("v.info", map = options['input'], env = tenv).splitlines()
+ e = re.compile("Number of boundaries: +([0-9]+) +")
+ for line in lines:
+ mo = e.search(line)
+ if mo:
+ num_bound = int(mo.group(1))
+ break
+ if num_bound == 0:
+ grass.fatal("Input vector map contains no boundaries.")
+
+ grass.exec_command("v.category", type = 'area', **options)
+
+ sys.exit(0)
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
Property changes on: grass/trunk/scripts/v.centroids/v.centroids.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Added: grass/trunk/scripts/v.convert.all/v.convert.all.py
===================================================================
--- grass/trunk/scripts/v.convert.all/v.convert.all.py (rev 0)
+++ grass/trunk/scripts/v.convert.all/v.convert.all.py 2008-08-18 15:58:53 UTC (rev 32857)
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+############################################################################
+#
+# MODULE: v.convert.all
+# AUTHOR(S): Markus Neteler, converted to Python by Glynn Clements
+# PURPOSE: converts all old GRASS < V5.7 vector maps to current format
+# in current mapset
+# COPYRIGHT: (C) 2004, 2008 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%Module
+#% description: Convert all old GRASS < Ver5.7 vector maps in current mapset to current format
+#% keywords: vector, import
+#%end
+
+import sys
+import grass
+
+def main():
+ env = grass.gisenv()
+ mapset = env['MAPSET']
+ converted = 0
+ ret = 0
+ for vect in grass.list_grouped('oldvect')[mapset]:
+ inmap = "%s@%s" % (vect, mapset)
+ outmap = vect.replace(".", "_")
+ if grass.run_command("v.convert", input = inmap, output = outmap) == 0:
+ converted += 1
+ else:
+ grass.warning("Error converting map %s to %s" % (inmap, outmap))
+ ret = 1
+
+ if converted < 1:
+ grass.warning("No vector maps converted as no old vector maps present in current mapset.")
+ else:
+ grass.message("Total %u vector maps in current mapset converted." % converted)
+ grass.message("Please verify new vector map(s) before deleting old vector map(s).")
+
+ sys.exit(ret)
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
Property changes on: grass/trunk/scripts/v.convert.all/v.convert.all.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Added: grass/trunk/scripts/v.in.sites.all/v.in.sites.all.py
===================================================================
--- grass/trunk/scripts/v.in.sites.all/v.in.sites.all.py (rev 0)
+++ grass/trunk/scripts/v.in.sites.all/v.in.sites.all.py 2008-08-18 15:58:53 UTC (rev 32857)
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE: v.in.sites.all
+# AUTHOR(S): Markus Neteler, converted to Python by Glynn Clements
+# PURPOSE: converts all old GRASS < V5.7 sites maps to vector maps
+# in current mapset
+# COPYRIGHT: (C) 2004, 2008 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%Module
+#% description: Converts all old GRASS < Ver5.7 sites maps in current mapset to vector maps.
+#% keywords: sites, vector, import
+#%End
+
+import sys
+import grass
+
+def main():
+ env = grass.gisenv()
+ mapset = env['MAPSET']
+ converted = 0
+ ret = 0
+ for site in grass.list_grouped('sites')[mapset]:
+ inmap = "%s@%s" % (site, mapset)
+ outmap = site.replace(".", "_") + "_points"
+ grass.message("Processing %s -> %s" % (inmap, outmap))
+ if grass.run_command("v.in.sites", input = inmap, output = outmap) == 0:
+ converted += 1
+ else:
+ grass.warning("Error converting map %s to %s" % (inmap, outmap))
+ ret = 1
+
+ if converted < 1:
+ grass.warning("No sites maps converted as no old sites maps present in current mapset.")
+ else:
+ grass.message("Total %u sites maps in current mapset converted to vector maps (original names extended by '_points')" % converted)
+ grass.message("Please verify new vector map(s) before deleting old sites map(s).")
+
+ sys.exit(ret)
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
Property changes on: grass/trunk/scripts/v.in.sites.all/v.in.sites.all.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Added: grass/trunk/scripts/v.what.vect/v.what.vect.py
===================================================================
--- grass/trunk/scripts/v.what.vect/v.what.vect.py (rev 0)
+++ grass/trunk/scripts/v.what.vect/v.what.vect.py 2008-08-18 15:58:53 UTC (rev 32857)
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+#
+############################################################################
+#
+# MODULE: v.what.vect
+# AUTHOR(S): Markus Neteler, converted to Python by Glynn Clements
+# PURPOSE: Uploads attributes at the location of vector points to the table.
+# COPYRIGHT: (C) 2005, 2008 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%Module
+#% description: Uploads vector values at positions of vector points to the table.
+#% keywords: vector, database, attribute table
+#%End
+
+#%option
+#% key: vector
+#% type: string
+#% key_desc: name
+#% gisprompt: old,vector,vector
+#% description: Points vector map to modify
+#% required : yes
+#%end
+#%option
+#% key: layer
+#% type: integer
+#% description: Layer in the vector to be modified
+#% answer: 1
+#% required : no
+#%end
+#%option
+#% key: column
+#% type: string
+#% description: Column to be updated with the query result
+#% required : yes
+#%end
+#%option
+#% key: qvector
+#% type: string
+#% key_desc: name
+#% gisprompt: old,vector,vector
+#% description: Vector map to be queried
+#% required : yes
+#%end
+#%option
+#% key: qlayer
+#% type: integer
+#% description: Layer of the query vector containg data
+#% answer: 1
+#% required : no
+#%end
+#%option
+#% key: qcolumn
+#% type: string
+#% description: Column to be queried
+#% required : yes
+#%end
+#%option
+#% key: dmax
+#% type: double
+#% description: Maximum query distance in map units
+#% answer: 0.0
+#% required: no
+#%end
+
+import sys
+import grass
+
+def main():
+ grass.exec_command(
+ "v.distance",
+ fro = options['vector'],
+ to = options['qvector'],
+ column = options['column'],
+ to_column = options['qcolumn'],
+ upload = to_attr,
+ dmax = options['dmax'],
+ from_layer = options['layer'],
+ to_layer = options['qlayer '])
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
Property changes on: grass/trunk/scripts/v.what.vect/v.what.vect.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
More information about the grass-commit
mailing list