[GRASS-SVN] r60511 - in grass/trunk/lib/python/pygrass: docs gis raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue May 27 04:20:05 PDT 2014
Author: lucadelu
Date: 2014-05-27 04:20:05 -0700 (Tue, 27 May 2014)
New Revision: 60511
Modified:
grass/trunk/lib/python/pygrass/docs/gis.rst
grass/trunk/lib/python/pygrass/docs/index.rst
grass/trunk/lib/python/pygrass/docs/raster.rst
grass/trunk/lib/python/pygrass/gis/__init__.py
grass/trunk/lib/python/pygrass/gis/region.py
grass/trunk/lib/python/pygrass/raster/__init__.py
grass/trunk/lib/python/pygrass/raster/category.py
grass/trunk/lib/python/pygrass/raster/history.py
Log:
pygrass: improve documentation about grass database managment, region and raster
Modified: grass/trunk/lib/python/pygrass/docs/gis.rst
===================================================================
--- grass/trunk/lib/python/pygrass/docs/gis.rst 2014-05-27 10:05:07 UTC (rev 60510)
+++ grass/trunk/lib/python/pygrass/docs/gis.rst 2014-05-27 11:20:05 UTC (rev 60511)
@@ -1,3 +1,4 @@
+.. _GRASSdatabase-label:
GRASS database management
===============================
@@ -17,6 +18,8 @@
.. autoclass:: pygrass.gis.VisibleMapset
:members:
+.. _Region-label:
+
Region management
======================
Modified: grass/trunk/lib/python/pygrass/docs/index.rst
===================================================================
--- grass/trunk/lib/python/pygrass/docs/index.rst 2014-05-27 10:05:07 UTC (rev 60510)
+++ grass/trunk/lib/python/pygrass/docs/index.rst 2014-05-27 11:20:05 UTC (rev 60511)
@@ -22,6 +22,7 @@
vector
attributes
modules
+ messages
References
Modified: grass/trunk/lib/python/pygrass/docs/raster.rst
===================================================================
--- grass/trunk/lib/python/pygrass/docs/raster.rst 2014-05-27 10:05:07 UTC (rev 60510)
+++ grass/trunk/lib/python/pygrass/docs/raster.rst 2014-05-27 11:20:05 UTC (rev 60511)
@@ -153,6 +153,8 @@
>>> land.write_cats_rules('land_rules.csv', ';')
>>> land.read_cats_rules('land_rules.csv', ';')
+.. autoclass:: pygrass.raster.category.Category
+ :members:
.. _RasterRow-label:
@@ -210,6 +212,8 @@
>>> new.exist()
False
+.. autoclass:: pygrass.raster.RasterRow
+ :members:
.. _RasterRowIO-label:
@@ -233,8 +237,9 @@
[ 144.99488831 145.22894287 145.57142639]
>>> elev.close()
+.. autoclass:: pygrass.raster.RasterRowIO
+ :members:
-
.. _RasterSegment-label:
RastSegment
@@ -302,8 +307,9 @@
>>> elev.close()
>>> elev.remove()
+.. autoclass:: pygrass.raster.RasterSegment
+ :members:
-
.. _RasterNumpy-label:
RasterNumpy
@@ -342,8 +348,9 @@
True
>>> el.remove()
+.. autoclass:: pygrass.raster.RasterNumpy
+ :members:
-
.. _Buffer-label:
Buffer
@@ -384,14 +391,6 @@
:members:
-.. _Category-label:
-
-Category
---------
-
-.. autoclass:: pygrass.raster.category.Category
- :members:
-
.. _Raster library: http://grass.osgeo.org/programming7/rasterlib.html
.. _RowIO library: http://grass.osgeo.org/programming7/rowiolib.html
.. _Segmentation library: http://grass.osgeo.org/programming7/segmentlib.html
Modified: grass/trunk/lib/python/pygrass/gis/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/gis/__init__.py 2014-05-27 10:05:07 UTC (rev 60510)
+++ grass/trunk/lib/python/pygrass/gis/__init__.py 2014-05-27 11:20:05 UTC (rev 60511)
@@ -60,6 +60,8 @@
def set_current_mapset(mapset, location=None, gisdbase=None):
+ """Set the current mapset as working area
+ """
libgis.G_setenv('MAPSET', mapset)
if location:
libgis.G_setenv('LOCATION_NAME', location)
@@ -68,6 +70,7 @@
def make_mapset(mapset, location=None, gisdbase=None):
+ """Create a new mapset"""
res = libgis.G_make_mapset(gisdbase, location, mapset)
if res == -1:
raise GrassError("Cannot create new mapset")
@@ -83,6 +86,7 @@
>>> gisdbase.name == gisenv()['GISDBASE']
True
+ ..
"""
def __init__(self, gisdbase=''):
self.name = gisdbase
@@ -93,7 +97,8 @@
def _set_name(self, name):
self._name = _check(name, '', "GISDBASE")
- name = property(fget=_get_name, fset=_set_name)
+ name = property(fget=_get_name, fset=_set_name,
+ doc="Set or obtain the name of GISDBASE")
def __str__(self):
return self.name
@@ -122,6 +127,7 @@
for loc in self.locations():
yield Location(loc, self.name)
+ # TODO remove or complete this function
def new_location(self):
if libgis.G__make_location() != 0:
raise GrassError("Cannot create new location")
@@ -167,7 +173,8 @@
def _set_gisdb(self, gisdb):
self._gisdb = _check(gisdb, '', "GISDBASE")
- gisdbase = property(fget=_get_gisdb, fset=_set_gisdb)
+ gisdbase = property(fget=_get_gisdb, fset=_set_gisdb,
+ doc="Set or obtain the name of GISDBASE")
def _get_name(self):
return self._name
@@ -175,7 +182,8 @@
def _set_name(self, name):
self._name = _check(name, self._gisdb, "LOCATION_NAME")
- name = property(fget=_get_name, fset=_set_name)
+ name = property(fget=_get_name, fset=_set_name,
+ doc="Set or obtain the name of LOCATION")
def __getitem__(self, mapset):
if mapset in self.mapsets():
@@ -198,11 +206,20 @@
return 'Location(%r)' % self.name
def mapsets(self, pattern=None, permissions=True):
- """Return a list of the available mapsets. ::
+ """Return a list of the available mapsets.
+ :param pattern: the pattern to filter the result
+ :type pattern: str
+ :param permissions: check the permission of mapset
+ :type permissions: bool
+ :returns: a list of mapset's names
+
+ ::
+
>>> location = Location()
>>> location.mapsets()
['PERMANENT', 'user1']
+ ..
"""
mapsets = [mapset for mapset in self]
if permissions:
@@ -228,6 +245,8 @@
'nc_basic_spm_grass7'
>>> mapset.name
'user1'
+
+ ..
"""
def __init__(self, mapset='', location='', gisdbase=''):
self.gisdbase = gisdbase
@@ -241,7 +260,8 @@
def _set_gisdb(self, gisdb):
self._gisdb = _check(gisdb, '', "GISDBASE")
- gisdbase = property(fget=_get_gisdb, fset=_set_gisdb)
+ gisdbase = property(fget=_get_gisdb, fset=_set_gisdb,
+ doc="Set or obtain the name of GISDBASE")
def _get_loc(self):
return self._loc
@@ -249,7 +269,8 @@
def _set_loc(self, loc):
self._loc = _check(loc, self._gisdb, "LOCATION_NAME")
- location = property(fget=_get_loc, fset=_set_loc)
+ location = property(fget=_get_loc, fset=_set_loc,
+ doc="Set or obtain the name of LOCATION")
def _get_name(self):
return self._name
@@ -257,7 +278,8 @@
def _set_name(self, name):
self._name = _check(name, join(self._gisdb, self._loc), "MAPSET")
- name = property(fget=_get_name, fset=_set_name)
+ name = property(fget=_get_name, fset=_set_name,
+ doc="Set or obtain the name of MAPSET")
def __str__(self):
return self.name
@@ -281,6 +303,11 @@
* 'vect',
* 'view3d'
+ :param type: the type of element to query
+ :type type: str
+ :param pattern: the pattern to filter the result
+ :type pattern: str
+
::
>>> mapset = Mapset('PERMANENT')
@@ -290,6 +317,8 @@
['basins', 'elevation', ...]
>>> mapset.glist('rast', pattern='el*')
['elevation_shade', 'elevation']
+
+ ..
"""
if type not in ETYPE:
str_err = "Type %s is not valid, valid types are: %s."
@@ -307,6 +336,7 @@
return elist
def is_current(self):
+ """Check if the MAPSET is the working MAPSET"""
return (self.name == libgis.G_getenv('MAPSET') and
self.location == libgis.G_getenv('LOCATION_NAME') and
self.gisdbase == libgis.G_getenv('GISDBASE'))
@@ -331,6 +361,8 @@
>>> mapset = VisibleMapset('user1')
>>> mapset
['user1', 'PERMANENT']
+
+ ..
"""
def __init__(self, mapset, location='', gisdbase=''):
self.mapset = mapset
@@ -357,13 +389,21 @@
return lns
def _write(self, mapsets):
- """Write to SEARCH_PATH file the changes in the search path"""
+ """Write to SEARCH_PATH file the changes in the search path
+
+ :param mapsets: a list of mapset's names
+ :type mapsets: list
+ """
with open(self.spath, "w+") as f:
ms = self.location.mapsets()
f.write('%s' % '\n'.join([m for m in mapsets if m in ms]))
def add(self, mapset):
- """Add a mapset to the search path"""
+ """Add a mapset to the search path
+
+ :param mapset: a mapset's name
+ :type mapset: str
+ """
if mapset not in self.read() and mapset in self.location:
with open(self.spath, "a+") as f:
f.write('\n%s' % mapset)
@@ -371,13 +411,21 @@
raise TypeError('Mapset not found')
def remove(self, mapset):
- """Remove mapset to the search path"""
+ """Remove mapset to the search path
+
+ :param mapset: a mapset's name
+ :type mapset: str
+ """
mapsets = self.read()
mapsets.remove(mapset)
self._write(mapsets)
def extend(self, mapsets):
- """Add more mapsets to the search path"""
+ """Add more mapsets to the search path
+
+ :param mapsets: a list of mapset's names
+ :type mapsets: list
+ """
ms = self.location.mapsets()
final = self.read()
final.extend([m for m in mapsets if m in ms and m not in final])
Modified: grass/trunk/lib/python/pygrass/gis/region.py
===================================================================
--- grass/trunk/lib/python/pygrass/gis/region.py 2014-05-27 10:05:07 UTC (rev 60510)
+++ grass/trunk/lib/python/pygrass/gis/region.py 2014-05-27 11:20:05 UTC (rev 60511)
@@ -15,34 +15,37 @@
class Region(object):
+ """
+ ::
+
+ >>> default = Region(default=True)
+ >>> current_good = Region()
+ >>> current = Region()
+ >>> current.align('elevation')
+ >>> default == current
+ True
+ >>> current.cols
+ 1500
+ >>> current.ewres
+ 10.0
+ >>> current.cols = 3000
+ >>> current.ewres
+ 5.0
+ >>> current.ewres = 20.0
+ >>> current.cols
+ 750
+ >>> current.set_current()
+ >>> default == current
+ False
+ >>> current.get_default()
+ >>> default = Region(default=True)
+ >>> default == current
+ True
+ >>> current_good.set_current()
+
+ ..
+ """
def __init__(self, default=False):
- """::
-
- >>> default = Region(default=True)
- >>> current_good = Region()
- >>> current = Region()
- >>> current.align('elevation')
- >>> default == current
- True
- >>> current.cols
- 1500
- >>> current.ewres
- 10.0
- >>> current.cols = 3000
- >>> current.ewres
- 5.0
- >>> current.ewres = 20.0
- >>> current.cols
- 750
- >>> current.set_current()
- >>> default == current
- False
- >>> current.get_default()
- >>> default = Region(default=True)
- >>> default == current
- True
- >>> current_good.set_current()
- """
self.c_region = ctypes.pointer(libgis.Cell_head())
if default:
self.get_default()
@@ -61,7 +64,8 @@
"""Private function to set north value"""
self.c_region.contents.north = value
- north = property(fget=_get_n, fset=_set_n)
+ north = property(fget=_get_n, fset=_set_n,
+ doc="Set and obtain north coordinate")
def _get_s(self):
"""Private function to obtain south value"""
@@ -71,7 +75,8 @@
"""Private function to set south value"""
self.c_region.contents.south = value
- south = property(fget=_get_s, fset=_set_s)
+ south = property(fget=_get_s, fset=_set_s,
+ doc="Set and obtain south coordinate")
def _get_e(self):
"""Private function to obtain east value"""
@@ -81,7 +86,8 @@
"""Private function to set east value"""
self.c_region.contents.east = value
- east = property(fget=_get_e, fset=_set_e)
+ east = property(fget=_get_e, fset=_set_e,
+ doc="Set and obtain east coordinate")
def _get_w(self):
"""Private function to obtain west value"""
@@ -91,7 +97,8 @@
"""Private function to set west value"""
self.c_region.contents.west = value
- west = property(fget=_get_w, fset=_set_w)
+ west = property(fget=_get_w, fset=_set_w,
+ doc="Set and obtain west coordinate")
def _get_t(self):
"""Private function to obtain top value"""
@@ -101,7 +108,8 @@
"""Private function to set top value"""
self.c_region.contents.top = value
- top = property(fget=_get_t, fset=_set_t)
+ top = property(fget=_get_t, fset=_set_t,
+ doc="Set and obtain top value")
def _get_b(self):
"""Private function to obtain bottom value"""
@@ -111,7 +119,8 @@
"""Private function to set bottom value"""
self.c_region.contents.bottom = value
- bottom = property(fget=_get_b, fset=_set_b)
+ bottom = property(fget=_get_b, fset=_set_b,
+ doc="Set and obtain bottom value")
#----------RESOLUTION----------
def _get_rows(self):
@@ -123,7 +132,8 @@
self.c_region.contents.rows = value
self.adjust(rows=True)
- rows = property(fget=_get_rows, fset=_set_rows)
+ rows = property(fget=_get_rows, fset=_set_rows,
+ doc="Set and obtain number of rows")
def _get_cols(self):
"""Private function to obtain columns value"""
@@ -134,7 +144,8 @@
self.c_region.contents.cols = value
self.adjust(cols=True)
- cols = property(fget=_get_cols, fset=_set_cols)
+ cols = property(fget=_get_cols, fset=_set_cols,
+ doc="Set and obtain number of columns")
def _get_nsres(self):
"""Private function to obtain north-south value"""
@@ -145,7 +156,8 @@
self.c_region.contents.ns_res = value
self.adjust()
- nsres = property(fget=_get_nsres, fset=_set_nsres)
+ nsres = property(fget=_get_nsres, fset=_set_nsres,
+ doc="Set and obtain north-south resolution value")
def _get_ewres(self):
"""Private function to obtain east-west value"""
@@ -156,7 +168,8 @@
self.c_region.contents.ew_res = value
self.adjust()
- ewres = property(fget=_get_ewres, fset=_set_ewres)
+ ewres = property(fget=_get_ewres, fset=_set_ewres,
+ doc="Set and obtain east-west resolution value")
def _get_tbres(self):
"""Private function to obtain top-botton 3D value"""
@@ -167,7 +180,8 @@
self.c_region.contents.tb_res = value
self.adjust()
- tbres = property(fget=_get_tbres, fset=_set_tbres)
+ tbres = property(fget=_get_tbres, fset=_set_tbres,
+ doc="Set and obtain top-bottom 3D value")
@property
def zone(self):
@@ -228,12 +242,20 @@
#----------METHODS----------
def zoom(self, raster_name):
- """Shrink region until it meets non-NULL data from this raster map:"""
+ """Shrink region until it meets non-NULL data from this raster map
+
+ :param raster_name: the name of raster
+ :type raster_name: str
+ """
self._set_param('zoom', str(raster_name))
self.get_current()
def align(self, raster_name):
- """Adjust region cells to cleanly align with this raster map"""
+ """Adjust region cells to cleanly align with this raster map
+
+ :param raster_name: the name of raster
+ :type raster_name: str
+ """
self._set_param('align', str(raster_name))
self.get_current()
@@ -245,13 +267,20 @@
libgis.G_adjust_Cell_head(self.c_region, bool(rows), bool(cols))
def vect(self, vector_name):
- """Adjust bounding box of region using a vector ::
+ """Adjust bounding box of region using a vector
+ :param vector_name: the name of vector
+ :type vector_name: str
+
+ ::
+
>>> reg = Region()
>>> reg.vect('census')
>>> reg.get_bbox()
Bbox(230963.640878, 212125.562878, 645837.437393, 628769.374393)
>>> reg.get_default()
+
+ ..
"""
from grass.pygrass.vector import VectorTopo
vect = VectorTopo(vector_name)
@@ -289,6 +318,8 @@
>>> reg = Region()
>>> reg.get_bbox()
Bbox(228500.0, 215000.0, 645000.0, 630000.0)
+
+ ..
"""
from grass.pygrass.vector.basic import Bbox
return Bbox(north=self.north, south=self.south,
@@ -296,16 +327,22 @@
top=self.top, bottom=self.bottom)
def set_bbox(self, bbox):
- """Set region from Bbox ::
+ """Set region extent from Bbox
+ :param bbox: a Bbox object to set the extent
+ :type bbox: Bbox object
+
+ ::
+
>>> from grass.pygrass.vector.basic import Bbox
- >>> b = Bbox(230963.640878, 212125.562878,
- ... 645837.437393, 628769.374393)
+ >>> 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()
+
+ ..
"""
self.north = bbox.north
self.south = bbox.south
Modified: grass/trunk/lib/python/pygrass/raster/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/__init__.py 2014-05-27 10:05:07 UTC (rev 60510)
+++ grass/trunk/lib/python/pygrass/raster/__init__.py 2014-05-27 11:20:05 UTC (rev 60511)
@@ -56,7 +56,6 @@
Examples
--------
- ::
>>> elev = RasterRow('elevation')
>>> elev.exist()
True
@@ -91,7 +90,7 @@
Open a raster map using the *with statement*: ::
- >>> with RasterRow('elevation') as elev:
+ >>> with RasterRow('elevation') as elev:
... for row in elev[:3]:
... row[:4]
...
@@ -111,6 +110,11 @@
"""Private method that return the row using the read mode
call the `Rast_get_row` C function.
+ :param row: the number of row to obtain
+ :type row: int
+ :param row_buffer: specify the Buffer object that will be instantiate
+ :type row_buffer: bool
+
>>> elev = RasterRow('elevation')
>>> elev.open()
>>> elev[0] # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
@@ -129,24 +133,26 @@
@must_be_open
def put_row(self, row):
"""Private method to write the row sequentially.
+
+ :param row: a Row object to insert into raster
+ :type row: Buffer object
"""
libraster.Rast_put_row(self._fd, row.p, self._gtype)
def open(self, mode=None, mtype=None, overwrite=None):
"""Open the raster if exist or created a new one.
- Parameters
- ------------
+ :param mode: Specify if the map will be open with read or write mode
+ ('r', 'w')
+ :type mode: str
+ :param type: If a new map is open, specify the type of the map(`CELL`,
+ `FCELL`, `DCELL`)
+ :type type: str
+ :param overwrite: Use this flag to set the overwrite mode of existing
+ raster maps
+ :type overwrite: bool
- mode: string
- Specify if the map will be open with read or write mode ('r', 'w')
- type: string
- If a new map is open, specify the type of the map(`CELL`, `FCELL`,
- `DCELL`)
- overwrite: Boolean
- Use this flag to set the overwrite mode of existing raster maps
-
if the map already exist, automatically check the type and set:
* self.mtype
@@ -203,11 +209,24 @@
super(RasterRowIO, self).__init__(name, *args, **kargs)
def open(self, mode=None, mtype=None, overwrite=False):
+ """Open the raster if exist or created a new one.
+
+ :param mode: specify if the map will be open with read or write mode
+ ('r', 'w')
+ :type mode: str
+ :param type: if a new map is open, specify the type of the map(`CELL`,
+ `FCELL`, `DCELL`)
+ :type type: str
+ :param overwrite: use this flag to set the overwrite mode of existing
+ raster maps
+ :type overwrite: bool
+ """
super(RasterRowIO, self).open(mode, mtype, overwrite)
self.rowio.open(self._fd, self._rows, self._cols, self.mtype)
@must_be_open
def close(self):
+ """Function to close the raster"""
self.rowio.release()
libraster.Rast_close(self._fd)
# update rows and cols attributes
@@ -222,6 +241,10 @@
* the read mode and
* `rowcache` method
+ :param row: the number of row to obtain
+ :type row: int
+ :param row_buffer: Specify the Buffer object that will be instantiate
+ :type row_buffer: Buffer object
"""
if row_buffer is None:
row_buffer = Buffer((self._cols,), self.mtype)
@@ -260,7 +283,8 @@
raise ValueError(str_err.format(mode))
self._mode = mode
- mode = property(fget=_get_mode, fset=_set_mode)
+ mode = property(fget=_get_mode, fset=_set_mode,
+ doc="Set or obtain the opening mode of raster")
def __setitem__(self, key, row):
"""Return the row of Raster object, slice allowed."""
@@ -303,13 +327,10 @@
def get_row(self, row, row_buffer=None):
"""Return the row using the `segment.get_row` method
- Parameters
- ------------
-
- row: integer
- Specify the row number;
- row_buffer: Buffer object, optional
- Specify the Buffer object that will be instantiate.
+ :param row: specify the row number
+ :type row: int
+ :param row_buffer: specify the Buffer object that will be instantiate
+ :type row_buffer: Buffer object
"""
if row_buffer is None:
row_buffer = Buffer((self._cols), self.mtype)
@@ -319,13 +340,8 @@
def put_row(self, row, row_buffer):
"""Write the row using the `segment.put_row` method
- Parameters
- ------------
-
- row: integer
- Specify the row number;
- row_buffer: Buffer object
- Specify the Buffer object that will be write to the map.
+ :param row: a Row object to insert into raster
+ :type row: Buffer object
"""
self.segment.put_row(row, row_buffer)
@@ -333,13 +349,10 @@
def get(self, row, col):
"""Return the map value using the `segment.get` method
- Parameters
- ------------
-
- row: integer
- Specify the row number;
- col: integer
- Specify the column number.
+ :param row: Specify the row number
+ :type row: int
+ :param col: Specify the column number
+ :type col: int
"""
return self.segment.get(row, col)
@@ -347,15 +360,12 @@
def put(self, row, col, val):
"""Write the value to the map using the `segment.put` method
- Parameters
- ------------
-
- row: integer
- Specify the row number;
- col: integer
- Specify the column number.
- val: value
- Specify the value that will be write to the map cell.
+ :param row: Specify the row number
+ :type row: int
+ :param col: Specify the column number
+ :type col: int
+ :param val: Specify the value that will be write to the map cell
+ :type val: value
"""
self.segment.val.value = val
self.segment.put(row, col)
@@ -365,16 +375,15 @@
and copy the map to the segment files;
else, open a new segment map.
- Parameters
- ------------
-
- mode: string, optional
- Specify if the map will be open with read, write or read/write
- mode ('r', 'w', 'rw')
- mtype: string, optional
- Specify the map type, valid only for new maps: CELL, FCELL, DCELL;
- overwrite: Boolean, optional
- Use this flag to set the overwrite mode of existing raster maps
+ :param mode: specify if the map will be open with read, write or
+ read/write mode ('r', 'w', 'rw')
+ :type mode: str
+ :param mtype: specify the map type, valid only for new maps: CELL,
+ FCELL, DCELL
+ :type mtype: str
+ :param overwrite: use this flag to set the overwrite mode of existing
+ raster maps
+ :type overwrite: bool
"""
# read rows and cols from the active region
self._rows = libraster.Rast_window_rows()
@@ -433,11 +442,8 @@
def close(self, rm_temp_files=True):
"""Close the map, copy the segment files to the map.
- Parameters
- ------------
-
- rm_temp_files: bool
- If True all the segments file will be removed.
+ :param rm_temp_files: if True all the segments file will be removed
+ :type rm_temp_files: bool
"""
if self.mode == "w" or self.mode == "rw":
self.segment.flush()
@@ -537,7 +543,8 @@
raise ValueError(_("Mode type: {0} not supported.").format(mode))
self._mode = mode
- mode = property(fget=_get_mode, fset=_set_mode)
+ mode = property(fget=_get_mode, fset=_set_mode,
+ doc="Set or obtain the opening mode of raster")
def __array_wrap__(self, out_arr, context=None):
"""See:
@@ -584,10 +591,9 @@
self[i] = rst.get_row(i, buff)
def _write(self):
+ """Write the numpy array into map
"""
- r.in.bin input=/home/pietro/docdat/phd/thesis/gis/north_carolina/user1/.tmp/eraclito/14325.0 output=new title='' bytes=1,anull='' --verbose --overwrite north=228500.0 south=215000.0 east=645000.0 west=630000.0 rows=1350 cols=1500
-
- """
+ #r.in.bin input=/home/pietro/docdat/phd/thesis/gis/north_carolina/user1/.tmp/eraclito/14325.0 output=new title='' bytes=1,anull='' --verbose --overwrite north=228500.0 south=215000.0 east=645000.0 west=630000.0 rows=1350 cols=1500
if not self.exist() or self.mode != 'r':
self.flush()
buff = Buffer(self[0].shape, mtype=self.mtype)
@@ -602,11 +608,14 @@
and copy the map to the segment files;
else, open a new segment map.
- Parameters
- ------------
-
- mtype: string, optional
- Specify the map type, valid only for new maps: CELL, FCELL, DCELL;
+ :param mtype: specify the map type, valid only for new maps: CELL,
+ FCELL, DCELL;
+ :type mtype: str
+ :param null:
+ :type null:
+ :param overwrite: use this flag to set the overwrite mode of existing
+ raster maps
+ :type overwrite: bool
"""
if overwrite is not None:
self.overwrite = overwrite
@@ -627,6 +636,11 @@
self._fd = 1
def close(self, name=''):
+ """Function to close the map
+
+ :param name: the name of raster
+ :type name: str
+ """
if self.is_open():
name = name if name else self.name
if not name:
@@ -639,10 +653,10 @@
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
+ :param point: pair of coordinates in tuple object
+ :type point: tuple
+ :param region: the region to crop the request
+ :type region: Region object
"""
if not region:
region = Region()
Modified: grass/trunk/lib/python/pygrass/raster/category.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/category.py 2014-05-27 10:05:07 UTC (rev 60510)
+++ grass/trunk/lib/python/pygrass/raster/category.py 2014-05-27 11:20:05 UTC (rev 60511)
@@ -80,11 +80,12 @@
def _set_mtype(self, mtype):
if mtype.upper() not in ('CELL', 'FCELL', 'DCELL'):
#fatal(_("Raser type: {0} not supported".format(mtype) ) )
- raise ValueError(_("Raser type: {0} not supported".format(mtype)))
+ raise ValueError(_("Raster type: {0} not supported".format(mtype)))
self._mtype = mtype
self._gtype = RTYPE[self.mtype]['grass type']
- mtype = property(fget=_get_mtype, fset=_set_mtype)
+ mtype = property(fget=_get_mtype, fset=_set_mtype,
+ doc="Set or obtain raster data type")
def _get_title(self):
return libraster.Rast_get_cats_title(ctypes.byref(self.c_cats))
@@ -93,7 +94,8 @@
return libraster.Rast_set_cats_title(newtitle,
ctypes.byref(self.c_cats))
- title = property(fget=_get_title, fset=_set_title)
+ title = property(fget=_get_title, fset=_set_title,
+ doc="Set or obtain raster title")
def __str__(self):
return self.__repr__()
@@ -266,7 +268,11 @@
libraster.Rast_write_cats(self.name, ctypes.byref(self.c_cats))
def copy(self, category):
- """Copy from another Category class"""
+ """Copy from another Category class
+
+ :param category: Category class to be copied
+ :type category: Category object
+ """
libraster.Rast_copy_cats(ctypes.byref(self.c_cats), # to
ctypes.byref(category._cats)) # from
self._read_cats()
@@ -293,7 +299,12 @@
0.5:1.0:road
1.0:1.5:urban
- .."""
+ :param filename: the name of file with categories rules
+ :type filename: str
+ :param sep: the separator used to divide values and category
+ :type sep: str
+ ..
+ """
self.reset()
with open(filename, 'r') as f:
for row in f.readlines():
@@ -320,7 +331,12 @@
0.5:1.0:road
1.0:1.5:urban
- .."""
+ :param filename: the name of file with categories rules
+ :type filename: str
+ :param sep: the separator used to divide values and category
+ :type sep: str
+ ..
+ """
with open(filename, 'w') as f:
cats = []
for cat in self.__iter__():
Modified: grass/trunk/lib/python/pygrass/raster/history.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/history.py 2014-05-27 10:05:07 UTC (rev 60510)
+++ grass/trunk/lib/python/pygrass/raster/history.py 2014-05-27 11:20:05 UTC (rev 60511)
@@ -76,7 +76,8 @@
libraster.HIST_CREATOR,
ctypes.c_char_p(creator))
- creator = property(fget=_get_creator, fset=_set_creator)
+ creator = property(fget=_get_creator, fset=_set_creator,
+ doc="Set or obtain the creator of map")
#----------------------------------------------------------------------
#libraster.HIST_DATSRC_1
@@ -89,7 +90,8 @@
libraster.HIST_DATSRC_1,
ctypes.c_char_p(src1))
- src1 = property(fget=_get_src1, fset=_set_src1)
+ src1 = property(fget=_get_src1, fset=_set_src1,
+ doc="Set or obtain the first source of map")
#----------------------------------------------------------------------
#libraster.HIST_DATSRC_2
@@ -102,7 +104,8 @@
libraster.HIST_DATSRC_2,
ctypes.c_char_p(src2))
- src2 = property(fget=_get_src2, fset=_set_src2)
+ src2 = property(fget=_get_src2, fset=_set_src2,
+ doc="Set or obtain the second source of map")
#----------------------------------------------------------------------
#libraster.HIST_KEYWORD
@@ -115,7 +118,8 @@
libraster.HIST_KEYWRD,
ctypes.c_char_p(keyword))
- keyword = property(fget=_get_keyword, fset=_set_keyword)
+ keyword = property(fget=_get_keyword, fset=_set_keyword,
+ doc="Set or obtain the keywords of map")
#----------------------------------------------------------------------
#libraster.HIST_MAPID
@@ -132,7 +136,8 @@
libraster.HIST_MAPID,
ctypes.c_char_p(date_str))
- date = property(fget=_get_date, fset=_set_date)
+ date = property(fget=_get_date, fset=_set_date,
+ doc="Set or obtain the date of map")
#----------------------------------------------------------------------
#libraster.HIST_MAPSET
@@ -145,7 +150,8 @@
libraster.HIST_MAPSET,
ctypes.c_char_p(mapset))
- mapset = property(fget=_get_mapset, fset=_set_mapset)
+ mapset = property(fget=_get_mapset, fset=_set_mapset,
+ doc="Set or obtain the mapset of map")
#----------------------------------------------------------------------
#libraster.HIST_MAPTYPE
@@ -158,7 +164,8 @@
libraster.HIST_MAPTYPE,
ctypes.c_char_p(maptype))
- maptype = property(fget=_get_maptype, fset=_set_maptype)
+ maptype = property(fget=_get_maptype, fset=_set_maptype,
+ doc="Set or obtain the type of map")
#----------------------------------------------------------------------
#libraster.HIST_NUM_FIELDS
@@ -186,7 +193,8 @@
libraster.HIST_TITLE,
ctypes.c_char_p(title))
- title = property(fget=_get_title, fset=_set_title)
+ title = property(fget=_get_title, fset=_set_title,
+ doc="Set or obtain the title of map")
def append(self, obj):
"""Rast_append_history"""
More information about the grass-commit
mailing list