Selaa lähdekoodia

rewrite method to get pixel value from pair of coordinates for RasterNumpy

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53977 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 12 vuotta sitten
vanhempi
commit
70950ae2b0
1 muutettua tiedostoa jossa 14 lisäystä ja 0 poistoa
  1. 14 0
      lib/python/pygrass/raster/__init__.py

+ 14 - 0
lib/python/pygrass/raster/__init__.py

@@ -24,6 +24,7 @@ import grass.lib.rowio as librowio
 #
 from pygrass.errors import OpenError, must_be_open
 from pygrass.region import Region
+import pygrass.env as env
 
 #
 # import raster classes
@@ -650,6 +651,19 @@ class RasterNumpy(np.memmap, RasterAbstractBase):
         grasscore.try_remove(self.filename)
         self._fd = None
 
+    def get_value(self, point, region=None):
+        """This method returns the pixel value of a given pair of coordinates:
+
+        Parameters
+        ------------
+
+        point = pair of coordinates in tuple object
+        """
+        if not region:
+            region = Region()
+        x, y = env.coor2pixel(point.coords(), region)
+        return self[x][y]
+
 
 def random_map_only_columns(mapname, mtype, overwrite=True, factor=100):
     region = Region()