|
@@ -15,11 +15,11 @@ from grass.pygrass.shell.conversion import dict2html
|
|
|
|
|
|
|
|
|
class Region(object):
|
|
|
- """
|
|
|
- ::
|
|
|
+ """This class is design to easily access and modify GRASS computational
|
|
|
+ region. ::
|
|
|
|
|
|
>>> default = Region(default=True)
|
|
|
- >>> current_good = Region()
|
|
|
+ >>> current_original = Region()
|
|
|
>>> current = Region()
|
|
|
>>> current.align('elevation')
|
|
|
>>> default == current
|
|
@@ -41,7 +41,7 @@ class Region(object):
|
|
|
>>> default = Region(default=True)
|
|
|
>>> default == current
|
|
|
True
|
|
|
- >>> current_good.set_current()
|
|
|
+ >>> current_original.set_current()
|
|
|
|
|
|
..
|
|
|
"""
|
|
@@ -233,11 +233,27 @@ class Region(object):
|
|
|
return True
|
|
|
|
|
|
def keys(self):
|
|
|
+ """Return a list of valid keys. ::
|
|
|
+
|
|
|
+ >>> reg = Region()
|
|
|
+ >>> reg.keys() # doctest: +ELLIPSIS
|
|
|
+ [u'proj', u'zone', ..., u'cols', u'cells']
|
|
|
+
|
|
|
+ ..
|
|
|
+ """
|
|
|
return ['proj', 'zone', 'north', 'south', 'west', 'east',
|
|
|
'top', 'bottom', 'nsres', 'ewres', 'tbres', 'rows',
|
|
|
'cols', 'cells']
|
|
|
|
|
|
def items(self):
|
|
|
+ """Return a list of tuple with key and value. ::
|
|
|
+
|
|
|
+ >>> reg = Region()
|
|
|
+ >>> reg.items() # doctest: +ELLIPSIS
|
|
|
+ [(u'proj', 99), ..., (u'cells', 2025000)]
|
|
|
+
|
|
|
+ ..
|
|
|
+ """
|
|
|
return [(k, self.__getattribute__(k)) for k in self.keys()]
|
|
|
|
|
|
#----------METHODS----------
|
|
@@ -274,11 +290,11 @@ class Region(object):
|
|
|
|
|
|
::
|
|
|
|
|
|
- >>> reg = Region()
|
|
|
- >>> reg.vect('census')
|
|
|
- >>> reg.get_bbox()
|
|
|
- Bbox(230963.640878, 212125.562878, 645837.437393, 628769.374393)
|
|
|
- >>> reg.get_default()
|
|
|
+ >>> reg = Region()
|
|
|
+ >>> reg.vect('census')
|
|
|
+ >>> reg.get_bbox()
|
|
|
+ Bbox(230963.640878, 212125.562878, 645837.437393, 628769.374393)
|
|
|
+ >>> reg.get_default()
|
|
|
|
|
|
..
|
|
|
"""
|
|
@@ -313,11 +329,11 @@ class Region(object):
|
|
|
raise GrassError("Cannot change region (DEFAUL_WIND file).")
|
|
|
|
|
|
def get_bbox(self):
|
|
|
- """Return a Bbox object with the extension of the region ::
|
|
|
+ """Return a Bbox object with the extension of the region. ::
|
|
|
|
|
|
- >>> reg = Region()
|
|
|
- >>> reg.get_bbox()
|
|
|
- Bbox(228500.0, 215000.0, 645000.0, 630000.0)
|
|
|
+ >>> reg = Region()
|
|
|
+ >>> reg.get_bbox()
|
|
|
+ Bbox(228500.0, 215000.0, 645000.0, 630000.0)
|
|
|
|
|
|
..
|
|
|
"""
|
|
@@ -334,13 +350,13 @@ class Region(object):
|
|
|
|
|
|
::
|
|
|
|
|
|
- >>> from grass.pygrass.vector.basic import Bbox
|
|
|
- >>> b = Bbox(230963.640878, 212125.562878, 645837.437393, 628769.374393)
|
|
|
- >>> reg = Region()
|
|
|
- >>> reg.set_bbox(b)
|
|
|
- >>> reg.get_bbox()
|
|
|
- Bbox(230963.640878, 212125.562878, 645837.437393, 628769.374393)
|
|
|
- >>> reg.get_current()
|
|
|
+ >>> from grass.pygrass.vector.basic import Bbox
|
|
|
+ >>> b = Bbox(230963.640878, 212125.562878, 645837.437393, 628769.374393)
|
|
|
+ >>> reg = Region()
|
|
|
+ >>> reg.set_bbox(b)
|
|
|
+ >>> reg.get_bbox()
|
|
|
+ Bbox(230963.640878, 212125.562878, 645837.437393, 628769.374393)
|
|
|
+ >>> reg.get_current()
|
|
|
|
|
|
..
|
|
|
"""
|