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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 9 13:52:59 EDT 2009


Author: martinl
Date: 2009-05-09 13:52:58 -0400 (Sat, 09 May 2009)
New Revision: 37078

Modified:
   grass/branches/develbranch_6/lib/python/grass.py
Log:
glynn: Fix raster_info to handle D:M:S output from r.info
       (merge from trunk, r37072)


Modified: grass/branches/develbranch_6/lib/python/grass.py
===================================================================
--- grass/branches/develbranch_6/lib/python/grass.py	2009-05-09 16:24:17 UTC (rev 37077)
+++ grass/branches/develbranch_6/lib/python/grass.py	2009-05-09 17:52:58 UTC (rev 37078)
@@ -589,15 +589,20 @@
     
     warning("Unable to write history for <%s>. Raster map <%s> not found in current mapset." % (map, map))
     return False
-    
+
+def float_or_dms(s):
+    return sum(float(x) / 60 ** n for (n, x) in enumerate(s.split(':')))
+
 # run "r.info -rgstmpud ..." and parse output
 
 def raster_info(map):
     """Return information about a raster map (interface to `r.info')."""
     s = read_command('r.info', flags = 'rgstmpud', map = map)
     kv = parse_key_val(s)
-    for k in ['min', 'max', 'north', 'south', 'east', 'west', 'nsres', 'ewres']:
+    for k in ['min', 'max', 'north', 'south', 'east', 'west']:
 	kv[k] = float(kv[k])
+    for k in ['nsres', 'ewres']:
+	kv[k] = float_or_dms(kv[k])
     return kv
 
 # interface to r.mapcalc



More information about the grass-commit mailing list