[GRASS-SVN] r68494 - in grass-addons/grass7/raster: . r.out.ntv2
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue May 24 07:49:10 PDT 2016
Author: msieczka
Date: 2016-05-24 07:49:10 -0700 (Tue, 24 May 2016)
New Revision: 68494
Added:
grass-addons/grass7/raster/r.out.ntv2/
grass-addons/grass7/raster/r.out.ntv2/Makefile
grass-addons/grass7/raster/r.out.ntv2/r.out.ntv2.html
grass-addons/grass7/raster/r.out.ntv2/r.out.ntv2.py
Modified:
grass-addons/grass7/raster/Makefile
Log:
Publish r.out.ntv2 GRASS 7 Python addon.
Modified: grass-addons/grass7/raster/Makefile
===================================================================
--- grass-addons/grass7/raster/Makefile 2016-05-24 13:03:13 UTC (rev 68493)
+++ grass-addons/grass7/raster/Makefile 2016-05-24 14:49:10 UTC (rev 68494)
@@ -69,6 +69,7 @@
r.northerness.easterness \
r.out.arc \
r.out.legend \
+ r.out.ntv2 \
r.out.tiff \
r.popgrowth \
r.random.weight \
Added: grass-addons/grass7/raster/r.out.ntv2/Makefile
===================================================================
--- grass-addons/grass7/raster/r.out.ntv2/Makefile (rev 0)
+++ grass-addons/grass7/raster/r.out.ntv2/Makefile 2016-05-24 14:49:10 UTC (rev 68494)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM=r.out.ntv2
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Added: grass-addons/grass7/raster/r.out.ntv2/r.out.ntv2.html
===================================================================
--- grass-addons/grass7/raster/r.out.ntv2/r.out.ntv2.html (rev 0)
+++ grass-addons/grass7/raster/r.out.ntv2/r.out.ntv2.html 2016-05-24 14:49:10 UTC (rev 68494)
@@ -0,0 +1,16 @@
+<h2>DESCRIPTION</h2>
+
+<em>r.out.ntv2</em> converts a pair of GRASS raster maps containing longitude and lattitude coordinate offsets into an <a href="http://trac.osgeo.org/proj/wiki/GenParms#nadgrids-GridBasedDatumAdjustments">g NTv2 datum shift</a> file.
+
+<p>NTv2 format supports only single-precission floating point data. GRASS double-precision DCELL data need to be reduced to FCELL before export, eg. using <a href="r.mapcalc.html">r.mapcalc</a> <code>float()</code> function.
+
+<p>The user should adjust the region and resolution to match the input raster maps before export, using <a href="g.region.html">g.region</a>.
+
+<p>PROJ.4 and the software the depend on it, including GDAL, GRASS, QGIS, assume any NTv2 grid's destination coordinate system is WGS84. The values in the grid's header set with <code>majort</code>, <code>minort</code>, <code>systemt</code> parameters are ignored, same as the input coordinate system parameters (<code>majorf</code>, <code>minorf</code>, <code>systemf</code>). They are for documentation purposes only.
+
+<h2>SEE ALSO</h2>
+<a href="https://github.com/Esri/ntv2-file-routines">NTv2 format description by ESRI</a>
+
+<h2>AUTHOR</h2>
+Maciej Sieczka
+
Added: grass-addons/grass7/raster/r.out.ntv2/r.out.ntv2.py
===================================================================
--- grass-addons/grass7/raster/r.out.ntv2/r.out.ntv2.py (rev 0)
+++ grass-addons/grass7/raster/r.out.ntv2/r.out.ntv2.py 2016-05-24 14:49:10 UTC (rev 68494)
@@ -0,0 +1,142 @@
+#!/usr/bin/env python2
+#
+############################################################################
+#
+# MODULE: r.out.ntv2
+# AUTHOR(S): Maciej Sieczka
+# PURPOSE: Export NTv2 datum transformation grid.
+# COPYRIGHT: (C) 2016 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: Exports NTv2 datum transformation grid
+#%End
+
+#%option
+#% key: latshift
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Input raster map of lattitude datum shift values
+#% required : yes
+#%end
+
+#%option
+#% key: lonshift
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Input raster map of longitude datum shift values
+#% required : yes
+#%end
+
+#%option
+#% key: output
+#% type: string
+#% description: Output NTv2 datum transformation grid file
+#% gisprompt: new_file,file,output
+#% required: yes
+#%end
+
+#%option
+#% key: systemt
+#% type: string
+#% description: Transformation grid's destination coordinate system name
+#% required : no
+#% answer: WGS84
+#%end
+
+#%option
+#% key: majort
+#% type: string
+#% description: Major ellipsoid axis of the transformation grid's destination coordinate system
+#% required : no
+#% answer: 6378137
+#%end
+
+#%option
+#% key: minort
+#% type: string
+#% description: Minor ellipsoid axis of the transformation grid's destination coordinate system
+#% required : no
+#% answer: 6356752.314245
+#%end
+
+#%option
+#% key: systemf
+#% type: string
+#% description: Transformation grid's input coordinate system name
+#% required : no
+#% answer: UNKNOWN
+#%end
+
+#%option
+#% key: majorf
+#% type: string
+#% description: Major ellipsoid axis of the transformation grid's input coordinate system
+#% required : no
+#% answer: UNKNOWN
+#%end
+
+#%option
+#% key: minorf
+#% type: string
+#% description: Minor ellipsoid axis of the transformation grid's input coordinate system
+#% required : no
+#% answer: UNKNOWN
+#%end
+
+'''
+SYSTEM_F, SYSTEM_T, MAJOR_F, MINOR_F, MAJOR_T, MINOR_T are not used for
+anything in GDAL or PROJ.4. They will always assume the *_T system is WGS84 and
+the *_F system's parameters are simply ignored. It makes sense setting these
+for documentation's sake only.
+
+More about NTv2 format on https://github.com/Esri/ntv2-file-routines.
+'''
+
+import atexit, sys, uuid, time
+from grass.script import core as grass
+
+tmp_group = str(uuid.uuid4())
+
+def cleanup():
+ grass.run_command("g.remove",
+ type = "group",
+ name = tmp_group,
+ flags = "f",
+ quiet = True)
+
+def main():
+ grass.run_command("i.group",
+ input = (options["latshift"], options["lonshift"]),
+ group = tmp_group,
+ quiet = True)
+
+ grass.run_command("r.out.gdal",
+ input = tmp_group,
+ output = options["output"],
+ format = "NTv2",
+ type = "Float32",
+ quiet = True,
+ metaopt = ("CREATED="+time.strftime("%Y%m%d"),
+ "GS_TYPE=SECONDS",
+ "SYSTEM_T="+options["systemt"],
+ "MAJOR_T="+options["majort"],
+ "MINOR_T="+options["minort"],
+ "SYSTEM_F="+options["systemf"],
+ "MAJOR_F="+options["majorf"],
+ "MINOR_F="+options["minorf"],
+ "PARENT=NONE",
+ "SUB_NAME=NONE",
+ "UPDATED="+time.strftime("%H%M%S"),
+ "VERSION=NTv2.0"))
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ atexit.register(cleanup)
+ sys.exit(main())
+
Property changes on: grass-addons/grass7/raster/r.out.ntv2/r.out.ntv2.py
___________________________________________________________________
Added: svn:executable
+ *
More information about the grass-commit
mailing list