[GRASS-SVN] r67746 - in grass/branches/releasebranch_7_0/scripts: r.import v.import

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Feb 6 11:37:33 PST 2016


Author: martinl
Date: 2016-02-06 11:37:33 -0800 (Sat, 06 Feb 2016)
New Revision: 67746

Modified:
   grass/branches/releasebranch_7_0/scripts/r.import/r.import.py
   grass/branches/releasebranch_7_0/scripts/v.import/v.import.py
Log:
r.import + v.import: add -o flag
         (merge r67632 + r67634 from trunk)


Modified: grass/branches/releasebranch_7_0/scripts/r.import/r.import.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/r.import/r.import.py	2016-02-06 19:31:54 UTC (rev 67745)
+++ grass/branches/releasebranch_7_0/scripts/r.import/r.import.py	2016-02-06 19:37:33 UTC (rev 67746)
@@ -8,7 +8,7 @@
 #
 # PURPOSE:      Import and reproject on the fly
 #
-# COPYRIGHT:    (C) 2015 GRASS development team
+# COPYRIGHT:    (C) 2015-2016 GRASS development team
 #
 #               This program is free software under the GNU General
 #               Public License (>=v2). Read the file COPYING that
@@ -103,8 +103,12 @@
 #% key: l
 #% description: Force Lat/Lon maps to fit into geographic coordinates (90N,S; 180E,W)
 #%end
+#%flag
+#% key: o
+#% label: Override projection check (use current location's projection)
+#% description: Assume that the dataset has same projection as the current location
+#%end
 
-
 import sys
 import os
 import atexit
@@ -188,8 +192,10 @@
 
     # try r.in.gdal directly first
     additional_flags = 'l' if flags['l'] else ''
-    if grass.run_command('r.in.gdal', input=GDALdatasource, flags='j',
-                         errors='status', quiet=True) == 0:
+    if flags['o']:
+        additional_flags += 'o'
+    if flags['o'] or grass.run_command('r.in.gdal', input=GDALdatasource, flags='j',
+                                       errors='status', quiet=True) == 0:
         parameters = dict(input=GDALdatasource, output=output,
                           memory=memory, flags='k' + additional_flags)
         if bands:

Modified: grass/branches/releasebranch_7_0/scripts/v.import/v.import.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/v.import/v.import.py	2016-02-06 19:31:54 UTC (rev 67745)
+++ grass/branches/releasebranch_7_0/scripts/v.import/v.import.py	2016-02-06 19:37:33 UTC (rev 67746)
@@ -86,8 +86,12 @@
 #% key: l
 #% description: List available OGR layers in data source and exit
 #%end
+#%flag
+#% key: o
+#% label: Override projection check (use current location's projection)
+#% description: Assume that the dataset has same projection as the current location
+#%end
 
-
 import sys
 import os
 import atexit
@@ -129,9 +133,12 @@
     output = options['output']
     layers = options['layer']
 
-    vflags = None
+    vflags = ''
     if options['extent'] == 'region':
-        vflags = 'r'
+        vflags += 'r'
+    if flags['o']:
+        vflags += 'o'
+
     vopts = {}
     if options['encoding']:
         vopts['encoding'] = options['encoding']
@@ -188,8 +195,8 @@
     os.environ['GISRC'] = str(tgtgisrc)
 
     # try v.in.ogr directly
-    if grass.run_command('v.in.ogr', input=OGRdatasource, flags='j',
-                         errors='status', quiet=True) == 0:
+    if flags['o'] or grass.run_command('v.in.ogr', input=OGRdatasource, flags='j',
+                                       errors='status', quiet=True) == 0:
         try:
             grass.run_command('v.in.ogr', input=OGRdatasource,
                               flags=vflags, **vopts)



More information about the grass-commit mailing list