[GRASS-SVN] r61455 - grass/trunk/temporal/t.rast.to.rast3

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 30 04:12:39 PDT 2014


Author: huhabla
Date: 2014-07-30 04:12:39 -0700 (Wed, 30 Jul 2014)
New Revision: 61455

Modified:
   grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
   grass/trunk/temporal/t.rast.to.rast3/test.t.rast.to.rast3.sh
Log:
t.rast.to.rast3: Fixed ticket #2366 by applying the patch from Anna


Modified: grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
===================================================================
--- grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py	2014-07-30 08:33:06 UTC (rev 61454)
+++ grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py	2014-07-30 11:12:39 UTC (rev 61455)
@@ -52,6 +52,12 @@
 
     maps = sp.get_registered_maps_as_objects_by_granularity()
     num_maps = len(maps)
+    # get datatype of the first map
+    if maps:
+        maps[0][0].select()
+        datatype = maps[0][0].metadata.get_datatype()
+    else:
+        datatype = None
 
     # Get the granularity and set bottom, top and top-bottom resolution
     granularity = sp.get_granularity()
@@ -112,7 +118,12 @@
 
     # Create a NULL map to fill the gaps
     null_map = "temporary_null_map_%i" % os.getpid()
-    grass.mapcalc("%s = null()" % (null_map))
+    if datatype == 'DCELL':
+        grass.mapcalc("%s = double(null())" % (null_map))
+    elif datatype == 'FCELL':
+        grass.mapcalc("%s = float(null())" % (null_map))
+    else:
+        grass.mapcalc("%s = null()" % (null_map))
 
     if maps:
         count = 0

Modified: grass/trunk/temporal/t.rast.to.rast3/test.t.rast.to.rast3.sh
===================================================================
--- grass/trunk/temporal/t.rast.to.rast3/test.t.rast.to.rast3.sh	2014-07-30 08:33:06 UTC (rev 61454)
+++ grass/trunk/temporal/t.rast.to.rast3/test.t.rast.to.rast3.sh	2014-07-30 11:12:39 UTC (rev 61455)
@@ -5,12 +5,12 @@
 # The region setting should work for UTM and LL test locations
 g.region s=0 n=80 w=0 e=120 b=0 t=1 res=10 res3=10 -p3
 
-r.mapcalc --o expr="prec_1 = 100"
-r.mapcalc --o expr="prec_2 = 200"
-r.mapcalc --o expr="prec_3 = 300"
-r.mapcalc --o expr="prec_4 = 400"
-r.mapcalc --o expr="prec_5 = 500"
-r.mapcalc --o expr="prec_6 = 600"
+r.mapcalc --o expr="prec_1 = 100.0"
+r.mapcalc --o expr="prec_2 = 200.0"
+r.mapcalc --o expr="prec_3 = 300.0"
+r.mapcalc --o expr="prec_4 = 400.0"
+r.mapcalc --o expr="prec_5 = 500.0"
+r.mapcalc --o expr="prec_6 = 600.0"
 
 n1=`g.tempfile pid=1 -d`
 



More information about the grass-commit mailing list