浏览代码

db.out.ogr: also support attribute export in case of line and area vectors; support for multilayers

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@55589 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 12 年之前
父节点
当前提交
9c0673b25c
共有 2 个文件被更改,包括 18 次插入5 次删除
  1. 8 1
      scripts/db.out.ogr/db.out.ogr.html
  2. 10 4
      scripts/db.out.ogr/db.out.ogr.py

+ 8 - 1
scripts/db.out.ogr/db.out.ogr.html

@@ -1,8 +1,15 @@
 <h2>DESCRIPTION</h2>
 
-<em>db.out.ogr</em> exports GRASS attribute tables into various formats as
+<em>db.out.ogr</em> exports GRASS GIS attribute tables into various formats as
 supported by the OGR driver on the local system (CSV, DBF,
 PostgreSQL, SQLite, MySQL, ODBC, etc.).
+<p>
+The <em>dsn</em> parameter is commonly the output file name (if the path is not
+defined, too, the module will attempt write to the current directory). In case
+of a database connection as output, the connection string has to be specified.
+<p>
+The <em>layer</em> parameter is needed if the attribute table to be exported
+is linked as non-default layer to a vector map.
 
 <h2>EXAMPLES</h2>
 

+ 10 - 4
scripts/db.out.ogr/db.out.ogr.py

@@ -32,6 +32,10 @@
 #% required : yes
 #%end
 
+#%option G_OPT_V_FIELD
+#% required: no
+#%end
+
 #%option
 #% key: format
 #% type: string
@@ -55,6 +59,7 @@ from grass.script import core as grass
 
 def main():
     input = options['input']
+    layer = options['layer']
     format = options['format']
     dsn = options['dsn']
     table = options['table']
@@ -73,12 +78,13 @@ def main():
 	grass.fatal(_("File <%s> already exists") % dbffile)
 
     if olayer:
-	if grass.run_command('v.out.ogr', quiet = True, input = input, dsn = dsn,
-			     format = format, type = 'point', olayer = olayer) != 0:
+	if grass.run_command('v.out.ogr', flags = 'c', quiet = True, input = input, layer = layer,
+			     dsn = dsn,
+			     format = format, type = 'point,line,area', olayer = olayer) != 0:
 	    sys.exit(1)
     else:
-	if grass.run_command('v.out.ogr', quiet = True, input = input, dsn = dsn,
-			     format = format, type = 'point') != 0:
+	if grass.run_command('v.out.ogr', flags = 'c', quiet = True, input = input, layer = layer,
+			     dsn = dsn, format = format, type = 'point,line,area') != 0:
 	    sys.exit(1)
 
     if format == "ESRI_Shapefile":