[GRASS-dev] [GRASS GIS] #547: Raster query in wxGUI

#547: Raster query in wxGUI
---------------------------+------------------------------------------------
Reporter: hcho | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-trunk
Keywords: raster, query | Platform: Linux
      Cpu: x86-32 |
---------------------------+------------------------------------------------
GRASS_REGION is set to the current display settings before raster queries
in gui/wxpython/gui_modules/mapdisp.py line 1117. However, the only
changes r.what can see are nsres, ewres, nrows, and ncols. East, west,
north, and south remain unchanged even after zooming/panning. Any ideas?

WxGUI uses the display region/resolution for raster query (compReg=False
in line 1152). Setting aside the above issue, why can't we just use the
computational region for raster queries? Differences between the
computational and display regions cause a cell-alignment problem where the
user gets several different values within a single cell. For example, if I
click eastern part of a cell, I get the correct value. But, if I click
western part of the cell, I get the value of the left-adjacent cell. When
I removed the compReg=False option, this problem disappeared.

R.what already takes care of everything related to query in the
computational region, and what we need to pass to it is just a map name
and coordinates. I don't see the need for GRASS_REGION and compReg=False.
Am I missing something?

Thanks.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/547&gt;
GRASS GIS <http://grass.osgeo.org>

#547: Raster query in wxGUI
---------------------+------------------------------------------------------
  Reporter: hcho | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone:
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: raster, query
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Changes (by hcho):

  * milestone: 6.4.0 =>

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/547#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#547: Raster query in wxGUI
---------------------+------------------------------------------------------
  Reporter: hcho | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: raster, query
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Changes (by hcho):

  * milestone: => 7.0.0

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/547#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#547: Raster query in wxGUI
---------------------+------------------------------------------------------
  Reporter: hcho | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: raster, query
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by hcho):

OK, I think I figured out why it happens. r.what and v.what run in
GMConsole.cmdThread.RunCmd, and cmdThread takes a snapshot of os.environ
when it's initialized at goutput.py line 163. No changes made to
os.environ afterward can be readable by any GRASS modules running in a
thread. I guess this issue can cause other problems somewhere else.

Still, I think we shouldn't use GRASS_REGION for r.what.

Any comments?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/547#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#547: Raster query in wxGUI
---------------------+------------------------------------------------------
  Reporter: hcho | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: raster, query
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by hcho):

Hmm.... I was wrong!

os.environ["GRASS_REGION"] is passed to r.what correctly only for the
*first* query. After that, r.what cannot see any changes to this variable.
Now, I'm puzzled...

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/547#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#547: Raster query in wxGUI
---------------------+------------------------------------------------------
  Reporter: hcho | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: raster, query
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by glynn):

Replying to [comment:4 hcho]:

> os.environ!["GRASS_REGION"] is passed to r.what correctly only for the
*first* query. After that, r.what cannot see any changes to this variable.
Now, I'm puzzled...

Please don't use os.environ for per-command environment settings.
subprocess.Popen() has an "env" parameter; use it!

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/547#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#547: Raster query in wxGUI
---------------------+------------------------------------------------------
  Reporter: hcho | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: raster, query
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by hcho):

Thanks for clarification, Glynn.

Because GRASS_REGION is not properly passed to r.what, querying outside
the initial extent (after panning) gives NULL. Note that r.what complains
when query coordinates are outside the current region (GRASS_REGION in
this case).

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/547#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#547: Raster query in wxGUI
---------------------+------------------------------------------------------
  Reporter: hcho | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: raster, query, r.what
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Changes (by hamish):

  * keywords: raster, query => raster, query, r.what

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/547#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#547: Raster query in wxGUI
---------------------+------------------------------------------------------
  Reporter: hcho | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: raster, query, r.what
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Changes (by martinl):

  * status: new => closed
  * resolution: => fixed

Comment:

No activity for 3 years. wxGUI development is continuing. Probably out-
dated issue, closing, please re-open if needed.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/547#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>