[GRASS-SVN] r42898 - grass-addons/raster/r.rast4d/bin
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 26 05:25:30 EDT 2010
Author: neteler
Date: 2010-07-26 09:25:30 +0000 (Mon, 26 Jul 2010)
New Revision: 42898
Added:
grass-addons/raster/r.rast4d/bin/tg.decades.calc
Log:
new
Added: grass-addons/raster/r.rast4d/bin/tg.decades.calc
===================================================================
--- grass-addons/raster/r.rast4d/bin/tg.decades.calc (rev 0)
+++ grass-addons/raster/r.rast4d/bin/tg.decades.calc 2010-07-26 09:25:30 UTC (rev 42898)
@@ -0,0 +1,72 @@
+#!/bin/sh
+############################################################################
+#
+# AUTHOR(S): Markus Neteler
+# PURPOSE: GRASS temporal data management: create decades
+# COPYRIGHT: (C) 2008 by Markus Neteler, 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: Calculate decades (10 days) from raster maps in in the grass sqlite database
+#% keywords: raster, database
+#%End
+
+#Only run if started in GRASS
+if [ -z "$GISBASE" ] ; then
+ echo "You must be in GRASS GIS to run this program." >&2
+ exit 1
+fi
+
+# GUI is not very useful here, skip it if no args are given
+if [ "$#" -gt 0 ] ; then
+ if [ "$1" != "@ARGS_PARSED@" ] ; then
+ exec g.parser "$0" "$@"
+ fi
+else
+ # no args given
+ GIS_FLAG_A=0
+ GIS_FLAG_R=0
+fi
+
+# source some library functions
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+
+source ${GISBASE}/etc/r.rast4d/globals/defines.sh
+
+g.message "Calculating decades in table <raster_decades>..."
+
+echo "
+DROP TABLE raster_decades;
+CREATE TABLE raster_decades AS
+ SELECT
+ name, ctime, mtime, vtime_start, vtime_end, vtime_duration,
+ year, month, day, m_decade
+ FROM
+ (
+ SELECT
+ name, ctime, mtime, vtime_start, vtime_end, vtime_duration,
+ substr(''||vtime_start,1,4) AS year,
+ substr(''||vtime_start,6,2) AS month,
+ substr(''||vtime_start,9,2) AS day,
+ CASE substr(''||vtime_start,9,1)
+ when '0' then 1
+ when '1' then 2
+ else 3
+ END AS m_decade
+ FROM raster_time_table
+ ) tmp
+ GROUP BY year, month, day, m_decade
+ ORDER BY year, month, day, m_decade;" | $GRAST4D_DBM $GRAST4D_DATABASE
+
+echo "Verify with:
+sqlite3 $GRAST4D_DATABASE"
+
+g.message "Done."
+exit 0
+
Property changes on: grass-addons/raster/r.rast4d/bin/tg.decades.calc
___________________________________________________________________
Added: svn:executable
+ *
More information about the grass-commit
mailing list