[GRASS-SVN] r53987 - in grass/trunk/lib/python/pygrass: . raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Nov 23 06:28:38 PST 2012
Author: lucadelu
Date: 2012-11-23 06:28:35 -0800 (Fri, 23 Nov 2012)
New Revision: 53987
Modified:
grass/trunk/lib/python/pygrass/functions.py
grass/trunk/lib/python/pygrass/raster/abstract.py
Log:
fix erroneus import
Modified: grass/trunk/lib/python/pygrass/functions.py
===================================================================
--- grass/trunk/lib/python/pygrass/functions.py 2012-11-23 14:22:51 UTC (rev 53986)
+++ grass/trunk/lib/python/pygrass/functions.py 2012-11-23 14:28:35 UTC (rev 53987)
@@ -11,6 +11,8 @@
import grass.lib.raster as libraster
from grass.script import core as grasscore
+from pygrass.errors import GrassError
+from pygrass.region import Region
def looking(filter_string, obj):
"""
@@ -92,4 +94,23 @@
True
"""
return (libraster.Rast_row_to_northing(row, region.c_region),
- libraster.Rast_col_to_easting(col, region.c_region))
\ No newline at end of file
+ libraster.Rast_col_to_easting(col, region.c_region))
+
+
+def get_raster_for_points(point, raster):
+ """Query a raster map for each point feature of a vector
+
+ Parameters
+ -------------
+
+ point: point vector object
+
+ raster: raster object
+ """
+ reg = Region()
+ if not point.is_open():
+ point.open()
+ if point.num_primitive_of('point') == 0:
+ raise GrassError(_("Vector doesn't contain points"))
+ values = [raster.get_value(poi.coords, reg) for poi in point.viter('point')]
+ return values
\ No newline at end of file
Modified: grass/trunk/lib/python/pygrass/raster/abstract.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/abstract.py 2012-11-23 14:22:51 UTC (rev 53986)
+++ grass/trunk/lib/python/pygrass/raster/abstract.py 2012-11-23 14:28:35 UTC (rev 53987)
@@ -21,7 +21,7 @@
#
# import pygrass modules
#
-import pygrass as functions
+from pygrass import functions
from pygrass.region import Region
from pygrass.errors import must_be_open
More information about the grass-commit
mailing list