[GRASS-SVN] r70883 - grass/trunk/gui/wxpython/iimage2target

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 15 15:02:34 PDT 2017


Author: ychemin
Date: 2017-04-15 15:02:34 -0700 (Sat, 15 Apr 2017)
New Revision: 70883

Modified:
   grass/trunk/gui/wxpython/iimage2target/ii2t_manager.py
Log:
Added connection from group elevation file (set by i.ortho.elev) to the GCP selection system, z value collected automatically on click in target map

Modified: grass/trunk/gui/wxpython/iimage2target/ii2t_manager.py
===================================================================
--- grass/trunk/gui/wxpython/iimage2target/ii2t_manager.py	2017-04-15 03:23:37 UTC (rev 70882)
+++ grass/trunk/gui/wxpython/iimage2target/ii2t_manager.py	2017-04-15 22:02:34 UTC (rev 70883)
@@ -1393,18 +1393,28 @@
             #TODO ADD ELEVATION FROM MAP AS HEIGHT
             if os.path.exists(self.file['elevation']):
                 #Parse the i.ortho.elev generated file
-                #to get the elevation at mapset map name
-                #FIXME
-                elevationmap='elevation at PERMANENT'
-                #Get the elevation height from the map given by i.ortho.elev
-                ret, msg = RunCommand('r.what',
+                #Get all lines from file
+                lines = open(self.file['elevation']).read().splitlines()
+                #Remove empty spaces in lines
+                lines = [x.replace(' ','') for x in lines]
+                #Extract map at mapset
+                elevationmap=lines[0].split(':')[1]+'@'+lines[1].split(':')[1]
+                #Make sure the region is set to the elevation map
+                ret, msg = RunCommand('g.region',
                                   parent=self,
                                   getErrorMsg=True,
                                   quiet=True,
-                                  _map=elevationmap,
-                                  method=self.gr_method,
-                                  flags=flags)
-                self.mapcoordlist[key][6] = ret
+                                  raster=elevationmap,
+                                  flags=None)
+                #Get the elevation height from the map given by i.ortho.elev
+                from subprocess import PIPE
+                from grass.pygrass.modules import Module
+                rwhat = Module('r.what',
+                                  map=elevationmap,
+                                  coordinates=[coord[0],coord[1]],
+                                  stdout_=PIPE)
+                self.mapcoordlist[key][6] = rwhat.outputs.stdout.split('|')[3].rstrip('\n')
+                self.list.SetStringItem(index, 6, str(self.mapcoordlist[key][6]))
 
             self.pointsToDrawTgt.GetItem(key - 1).SetCoords([coord0, coord1])
 



More information about the grass-commit mailing list