[GRASS-SVN] r37072 - grass/trunk/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 9 12:03:47 EDT 2009


Author: glynn
Date: 2009-05-09 12:03:47 -0400 (Sat, 09 May 2009)
New Revision: 37072

Modified:
   grass/trunk/lib/python/grass.py
Log:
Fix raster_info to handle D:M:S output from r.info


Modified: grass/trunk/lib/python/grass.py
===================================================================
--- grass/trunk/lib/python/grass.py	2009-05-09 15:37:07 UTC (rev 37071)
+++ grass/trunk/lib/python/grass.py	2009-05-09 16:03:47 UTC (rev 37072)
@@ -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