[GRASS-SVN] r44050 - grass/branches/develbranch_6/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Oct 26 11:54:15 EDT 2010


Author: martinl
Date: 2010-10-26 08:54:15 -0700 (Tue, 26 Oct 2010)
New Revision: 44050

Modified:
   grass/branches/develbranch_6/lib/python/raster.py
Log:
glynn: Fix raster_info() to handle min/max = NULL.


Modified: grass/branches/develbranch_6/lib/python/raster.py
===================================================================
--- grass/branches/develbranch_6/lib/python/raster.py	2010-10-26 14:35:13 UTC (rev 44049)
+++ grass/branches/develbranch_6/lib/python/raster.py	2010-10-26 15:54:15 UTC (rev 44050)
@@ -70,9 +70,18 @@
     
     @return parsed raster info
     """
+
+    def float_or_null(s):
+        if s == 'NULL':
+            return None
+        else:
+            return float(s)
+
     s = read_command('r.info', flags = 'rgstmpud', map = map)
     kv = parse_key_val(s)
-    for k in ['min', 'max', 'north', 'south', 'east', 'west']:
+    for k in ['min', 'max']:
+	kv[k] = float_or_null(kv[k])
+    for k in ['north', 'south', 'east', 'west']:
 	kv[k] = float(kv[k])
     for k in ['nsres', 'ewres']:
 	kv[k] = float_or_dms(kv[k])



More information about the grass-commit mailing list