Note: A new GRASS GIS stable version has been released: GRASS GIS 7.4. Go directly to the new manual page here
Bases: dict
Dictionary that remembers insertion order
and values equal to v (which defaults to None).
If key is not found, d is returned if given, otherwise KeyError is raised.
Pairs are returned in LIFO order if last is true or FIFO order if false.
If E is a dict instance, does: for k in E: od[k] = E[k] If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] Or if E is an iterable of items, does: for k, v in E: od[k] = v In either case, this is followed by: for k, v in F.items(): od[k] = v
Convert coordinates into a pixel row and col
>>> from grass.pygrass.gis.region import Region
>>> reg = Region()
>>> coor2pixel((reg.west, reg.north), reg)
(0.0, 0.0)
>>> coor2pixel((reg.east, reg.south), reg) == (reg.rows, reg.cols)
True
Copy a map
>>> copy(test_vector_name, 'mycensus', 'vector')
>>> rename('mycensus', 'mynewcensus', 'vector')
>>> remove('mynewcensus', 'vector')
This functions creates a vector map layer with lines that represent a stream network with two different graphs. The first graph contains a loop, the second can be used as directed graph.
This should be used in doc and unit tests to create location/mapset independent vector map layer.
param map_name: The vector map name that should be used
- 1(0,2) 3(2,2)
- /
- 1 / 2
- /
- 2(1,1)
10(1,-3)
This functions creates a vector map layer with points, lines, boundaries, centroids, areas, isles and attributes for testing purposes
This should be used in doc and unit tests to create location/mapset independent vector map layer. This map includes 3 points, 3 lines, 11 boundaries and 4 centroids. The attribute table contains cat, name and value columns.
Return a list of tuple contining the names of the:
Return the path of the libname contained in the module.
Deprecated since version 7.1: Use grass.script.utils.get_lib_path() instead.
Return the mapset of the raster map
>>> get_mapset_raster(test_raster_name) == getenv("MAPSET")
True
Return the mapset of the vector map
>>> get_mapset_vector(test_vector_name) == getenv("MAPSET")
True
Query a raster map for each point feature of a vector
test_vector_name=”Utils_test_vector” test_raster_name=”Utils_test_raster”
Example
>>> from grass.pygrass.vector import VectorTopo
>>> from grass.pygrass.raster import RasterRow
>>> from grass.pygrass.gis.region import Region
>>> region = Region()
>>> region.from_rast(test_raster_name)
>>> region.set_raster_region()
>>> ele = RasterRow(test_raster_name)
>>> copy(test_vector_name,'test_vect_2','vector')
>>> fire = VectorTopo('test_vect_2')
>>> fire.open(mode='r')
>>> l = get_raster_for_points(fire, ele, region=region)
>>> l[0]
(1, 620856.9585876337, 230066.3831321055, 111.2153883384)
>>> l[1]
(2, 625331.9185974908, 229990.82160762616, 89.978796115200012)
>>> fire.table.columns.add(test_raster_name,'double precision')
>>> test_raster_name in fire.table.columns
True
>>> get_raster_for_points(fire, ele, column=test_raster_name, region=region)
True
>>> fire.table.filters.select('name', test_raster_name)
Filters(u'SELECT name, Utils_test_raster FROM test_vect_2;')
>>> cur = fire.table.execute()
>>> r = cur.fetchall()
>>> r[0]
(u'Morrisville #3', 111.2153883384)
>>> r[1]
(u'Morrisville #1', 89.97879611520001)
>>> remove('test_vect_2','vect')
Parameters: |
|
---|
Return the current grass environment variables
>>> from grass.script.core import gisenv
>>> getenv("MAPSET") == gisenv()["MAPSET"]
True
Return if the name is valid
>>> is_clean_name('census')
True
>>> is_clean_name('0census')
True
>>> is_clean_name('census?')
True
>>> is_clean_name('cénsus')
False
>>> import grass.lib.vector as libvect
>>> sorted(looking(libvect, '*by_box*'))
['Vect_select_areas_by_box', 'Vect_select_isles_by_box',
'Vect_select_lines_by_box', 'Vect_select_nodes_by_box']
Convert row and col of a pixel into a coordinates
>>> from grass.pygrass.gis.region import Region
>>> reg = Region()
>>> pixel2coor((0, 0), reg) == (reg.north, reg.west)
True
>>> pixel2coor((reg.cols, reg.rows), reg) == (reg.south, reg.east)
True
Set sys.path looking in the the local directory GRASS directories.
Parameters: |
|
---|
Deprecated since version 7.1: Use grass.script.utils.set_path() instead.
Split a list in chunk.
>>> for chunk in split_in_chunk(range(25)): print chunk
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
(10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
(20, 21, 22, 23, 24)
>>> for chunk in split_in_chunk(range(25), 3): print chunk
(0, 1, 2)
(3, 4, 5)
(6, 7, 8)
(9, 10, 11)
(12, 13, 14)
(15, 16, 17)
(18, 19, 20)
(21, 22, 23)
(24,)
Note: A new GRASS GIS stable version has been released: GRASS GIS 7.4. Go directly to the new manual page here
Help Index | Topics Index | Keywords Index | Full Index
© 2003-2019 GRASS Development Team, GRASS GIS 7.2.4svn Reference Manual