[GRASS-SVN] r66969 - grass/trunk/scripts/v.import
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Nov 28 09:01:07 PST 2015
Author: martinl
Date: 2015-11-28 09:01:07 -0800 (Sat, 28 Nov 2015)
New Revision: 66969
Modified:
grass/trunk/scripts/v.import/v.import.py
Log:
v.import: add new parameters <epsg> and <datum_trans> to override input SRS
Modified: grass/trunk/scripts/v.import/v.import.py
===================================================================
--- grass/trunk/scripts/v.import/v.import.py 2015-11-28 16:37:56 UTC (rev 66968)
+++ grass/trunk/scripts/v.import/v.import.py 2015-11-28 17:01:07 UTC (rev 66969)
@@ -67,6 +67,21 @@
#% answer: 1e-13
#% guisection: Output
#%end
+#%option
+#% key: epsg
+#% type: integer
+#% options: 1-1000000
+#% guisection: Input SRS
+#% description: EPSG projection code
+#%end
+#%option
+#% key: datum_trans
+#% type: integer
+#% options: -1-100
+#% guisection: Input SRS
+#% label: Index number of datum transform parameters
+#% description: -1 to list available datum transform parameters
+#%end
#%flag
#% key: f
#% description: List supported OGR formats and exit
@@ -126,6 +141,14 @@
if options['encoding']:
vopts['encoding'] = options['encoding']
+ if options['datum_trans'] and options['datum_trans'] == '-1':
+ # list datum transform parameters
+ if not options['epsg']:
+ grass.fatal(_("Missing value for parameter <%s>") % 'epsg')
+
+ return grass.run_command('g.proj', epsg=options['epsg'],
+ datum_trans=options['datum_trans'])
+
grassenv = grass.gisenv()
tgtloc = grassenv['LOCATION_NAME']
tgtmapset = grassenv['MAPSET']
@@ -160,6 +183,12 @@
# switch to temp location
os.environ['GISRC'] = str(SRCGISRC)
+ if options['epsg']: # force given EPSG
+ kwargs = {}
+ if options['datum_trans']:
+ kwargs['datum_trans'] = options['datum_trans']
+ grass.run_command('g.proj', flags='c', epsg=options['epsg'], **kwargs)
+
# switch to target location
os.environ['GISRC'] = str(tgtgisrc)
@@ -181,6 +210,9 @@
# switch to temp location
os.environ['GISRC'] = str(SRCGISRC)
+ # print projection at verbose level
+ grass.verbose(grass.read_command('g.proj', flags='p').rstrip(os.linesep))
+
# make sure input is not xy
if grass.parse_command('g.proj', flags='g')['name'] == 'xy_location_unprojected':
grass.fatal(_("Coordinate reference system not available for input <%s>") % OGRdatasource)
More information about the grass-commit
mailing list