[GRASS-SVN] r68215 - in grass-addons/grass7/temporal: . t.rast.out.xyz
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Apr 6 06:58:47 PDT 2016
Author: lucadelu
Date: 2016-04-06 06:58:47 -0700 (Wed, 06 Apr 2016)
New Revision: 68215
Added:
grass-addons/grass7/temporal/t.rast.out.xyz/
grass-addons/grass7/temporal/t.rast.out.xyz/Makefile
grass-addons/grass7/temporal/t.rast.out.xyz/t.rast.out.xyz.html
grass-addons/grass7/temporal/t.rast.out.xyz/t.rast.out.xyz.py
Log:
t.rast.out.xyz: added module to export strds to xyz file
Added: grass-addons/grass7/temporal/t.rast.out.xyz/Makefile
===================================================================
--- grass-addons/grass7/temporal/t.rast.out.xyz/Makefile (rev 0)
+++ grass-addons/grass7/temporal/t.rast.out.xyz/Makefile 2016-04-06 13:58:47 UTC (rev 68215)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = t.rast.out.xyz
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Added: grass-addons/grass7/temporal/t.rast.out.xyz/t.rast.out.xyz.html
===================================================================
--- grass-addons/grass7/temporal/t.rast.out.xyz/t.rast.out.xyz.html (rev 0)
+++ grass-addons/grass7/temporal/t.rast.out.xyz/t.rast.out.xyz.html 2016-04-06 13:58:47 UTC (rev 68215)
@@ -0,0 +1,19 @@
+<h2>DESCRIPTION</h2>
+
+The t.rast.out.xyz module exports a space time raster dataset as a list
+of x,y,z values into an ASCII text file.
+
+<h2>EXAMPLE</h2>
+
+<div class="code"><pre>
+t.rast.out.xyz input=mystrds output=/tmp/mystrds.csv
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<a href="r.out.xyz.html">r.out.xyz</a>,
+<a href="t.rast.out.vtk.html">t.rast.out.vtk</a>
+
+<h2>AUTHOR</h2>
+
+Luca Delucchi (Fondazione Edmund Mach)
\ No newline at end of file
Added: grass-addons/grass7/temporal/t.rast.out.xyz/t.rast.out.xyz.py
===================================================================
--- grass-addons/grass7/temporal/t.rast.out.xyz/t.rast.out.xyz.py (rev 0)
+++ grass-addons/grass7/temporal/t.rast.out.xyz/t.rast.out.xyz.py 2016-04-06 13:58:47 UTC (rev 68215)
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE: t.rast.out.xyz
+# AUTHOR(S): Luca Delucchi
+#
+# PURPOSE: Export space time raster dataset to a CSV file.
+# COPYRIGHT: (C) 2011-2014 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (version 2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%module
+#% description: Export space time raster dataset to a CSV file.
+#% keyword: temporal
+#% keyword: raster
+#% keyword: export
+#% keyword: ASCII
+#% keyword: conversion
+#%end
+
+#%option G_OPT_STRDS_INPUT
+#% key: strds
+#%end
+
+#%option G_OPT_F_OUTPUT
+#% required: no
+#% description: Name for the output file or "-" in case stdout should be used
+#% answer: -
+#%end
+
+#%option G_OPT_T_WHERE
+#%end
+
+#%option G_OPT_F_SEP
+#%end
+
+import grass.script as gscript
+import grass.temporal as tgis
+
+
+def main(options, flags):
+ strds = options["strds"]
+ out_name = options["output"]
+ where = options["where"]
+ sep = options["separator"]
+ # Make sure the temporal database exists
+ tgis.init()
+ # We need a database interface
+ dbif = tgis.SQLDatabaseInterfaceConnection()
+ dbif.connect()
+
+ sp = tgis.open_old_stds(strds, "strds", dbif)
+ maps = sp.get_registered_maps_as_objects(where, "start_time", None)
+ if maps is None:
+ gscript.fatal(_("Space time raster dataset {st} seems to be "
+ "empty".format(st=strds)))
+ return 1
+ mapnames = [mapp.get_name() for mapp in maps]
+ try:
+ gscript.run_command("r.out.xyz", input=','.join(mapnames),
+ output=out_name, separator=sep,
+ overwrite=gscript.overwrite())
+ gscript.message(_("Space time raster dataset {st} exported to "
+ "{pa}".format(st=strds, pa=out_name)))
+ except:
+ gscript.fatal(_("Unable to export space time raster dataset "
+ "{st}".format(st=strds)))
+ return 1
+
+
+if __name__ == "__main__":
+ options, flags = gscript.parser()
+ main(options, flags)
More information about the grass-commit
mailing list