[GRASS-SVN] r69412 - grass/branches/releasebranch_7_2/lib/python/pygrass/raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Sep 8 17:09:35 PDT 2016
Author: huhabla
Date: 2016-09-08 17:09:35 -0700 (Thu, 08 Sep 2016)
New Revision: 69412
Modified:
grass/branches/releasebranch_7_2/lib/python/pygrass/raster/abstract.py
Log:
pygrass library: Fixed wrong region initialization in raster layer get_value() function
Modified: grass/branches/releasebranch_7_2/lib/python/pygrass/raster/abstract.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/pygrass/raster/abstract.py 2016-09-08 14:13:35 UTC (rev 69411)
+++ grass/branches/releasebranch_7_2/lib/python/pygrass/raster/abstract.py 2016-09-09 00:09:35 UTC (rev 69412)
@@ -189,10 +189,10 @@
def items(self):
return [(k, self.__getattribute__(k)) for k in self.keys()]
-
+
def __iter__(self):
return ((k, self.__getattribute__(k)) for k in self.keys())
-
+
def _repr_html_(self):
return dict2html(dict(self.items()), keys=self.keys(),
border='1', kdec='b')
@@ -436,6 +436,8 @@
call C function `Rast_get_cellhd`, `Rast_set_window`
+ return: The region that was used to set the computational region
+
"""
if self.is_open():
fatal("You cannot change the region if map is open")
@@ -449,6 +451,7 @@
libraster.Rast_get_cellhd(rastname, mapset,
region.byref())
self._set_raster_window(region)
+ return region
def set_region(self, region):
"""Set the computational region that can be different from the
@@ -473,13 +476,17 @@
"""This method returns the pixel value of a given pair of coordinates:
:param point: pair of coordinates in tuple object or class object with coords() method
+ :param region: The region that should be used for sampling,
+ default is the current computational region that can be set with set_region()
+ or set_region_from_rast()
"""
# Check for tuple
if type(point) != type([]) and type(point) != type(()):
point = point.coords()
-
+ # If no region was set, use the current computational region
if not region:
region = Region()
+ libraster.Rast_get_window(region.byref())
row, col = utils.coor2pixel(point, region)
if col < 0 or col > region.cols or row < 0 or row > region.rows:
return None
More information about the grass-commit
mailing list