[GRASS-SVN] r62198 - grass/trunk/lib/python/pygrass
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Oct 7 03:05:03 PDT 2014
Author: zarch
Date: 2014-10-07 03:05:03 -0700 (Tue, 07 Oct 2014)
New Revision: 62198
Modified:
grass/trunk/lib/python/pygrass/__init__.py
grass/trunk/lib/python/pygrass/functions.py
Log:
pygrass: Fix circular import dependency between gis.__init__ and functions
Modified: grass/trunk/lib/python/pygrass/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/__init__.py 2014-10-07 05:57:29 UTC (rev 62197)
+++ grass/trunk/lib/python/pygrass/__init__.py 2014-10-07 10:05:03 UTC (rev 62198)
@@ -1,19 +1 @@
# -*- coding: utf-8 -*-
-"""
-Created on Fri May 25 12:55:14 2012
-
- at author: pietro
-"""
-import grass.lib.gis as _libgis
-_libgis.G_gisinit('')
-import os as _os
-import sys as _sys
-
-from . import errors
-from . import gis
-from . import functions
-from . import raster
-from . import vector
-from . import modules
-from . import shell
-from . import messages
Modified: grass/trunk/lib/python/pygrass/functions.py
===================================================================
--- grass/trunk/lib/python/pygrass/functions.py 2014-10-07 05:57:29 UTC (rev 62197)
+++ grass/trunk/lib/python/pygrass/functions.py 2014-10-07 10:05:03 UTC (rev 62198)
@@ -1,20 +1,15 @@
# -*- coding: utf-8 -*-
-"""
-Created on Tue Jun 26 12:38:48 2012
-
- at author: pietro
-"""
import itertools
import fnmatch
import os
from sqlite3 import OperationalError
import grass.lib.gis as libgis
+libgis.G_gisinit('')
import grass.lib.raster as libraster
from grass.script import core as grasscore
from grass.pygrass.errors import GrassError
-from grass.pygrass.gis.region import Region
def looking(obj, filter_string):
@@ -196,7 +191,7 @@
libraster.Rast_col_to_easting(col, region.c_region))
-def get_raster_for_points(poi_vector, raster, column=None):
+def get_raster_for_points(poi_vector, raster, column=None, region=None):
"""Query a raster map for each point feature of a vector
Example
@@ -230,7 +225,9 @@
from math import isnan
if not column:
result = []
- reg = Region()
+ if region is None:
+ from grass.pygrass.gis.region import Region
+ region = Region()
if not poi_vector.is_open():
poi_vector.open()
if not raster.is_open():
@@ -238,7 +235,7 @@
if poi_vector.num_primitive_of('point') == 0:
raise GrassError(_("Vector doesn't contain points"))
for poi in poi_vector.viter('points'):
- val = raster.get_value(poi, reg)
+ val = raster.get_value(poi, region)
if column:
if val is not None and not isnan(val):
poi.attrs[column] = val
More information about the grass-commit
mailing list