GRASS Programmer's Manual
6.4.2(2012)
|
Functions | |
def | vector_db |
Return the database connection details for a vector map (interface to `v.db.connect -g'). | |
def | vector_layer_db |
Return the database connection details for a vector map layer. | |
def | vector_columns |
Return a dictionary (or a list) of the columns for the database table connected to a vector map (interface to `v.info. | |
def | vector_history |
Set the command history for a vector map to the command used to invoke the script (interface to `v.support'). | |
def | vector_info_topo |
Return information about a vector map (interface to `v.info. | |
def | vector_db_select |
Get attribute data of selected vector map layer. | |
def | vector_what |
Query vector map at given locations. |
def python.vector.vector_columns | ( | map, | |
layer = None , |
|||
getDict = True , |
|||
args | |||
) |
Return a dictionary (or a list) of the columns for the database table connected to a vector map (interface to `v.info.
-c').
>>> vector_columns(urbanarea, getDict = True) {'UA_TYPE': {'index': 4, 'type': 'CHARACTER'}, 'UA': {'index': 2, 'type': 'CHARACTER'}, 'NAME': {'index': 3, 'type': 'CHARACTER'}, 'OBJECTID': {'index': 1, 'type': 'INTEGER'}, 'cat': {'index': 0, 'type': 'INTEGER'}} >>> vector_columns(urbanarea, getDict = False) ['cat', 'OBJECTID', 'UA', 'NAME', 'UA_TYPE']
map | map name |
layer | layer number or name (None for all layers) |
getDict | True to return dictionary of columns otherwise list of column names is returned |
args | (v.info's arguments) |
Definition at line 97 of file vector.py.
References python::core.read_command().
def python.vector.vector_db | ( | map, | |
args | |||
) |
Return the database connection details for a vector map (interface to `v.db.connect -g').
Example:
>>> grass.vector_db('lakes') {1: {'layer': '1', 'name': '', 'database': '/home/martin/grassdata/nc_spm_08/PERMANENT/dbf/', 'driver': 'dbf', 'key': 'cat', 'table': 'lakes'}}
map | vector map |
args |
Definition at line 37 of file vector.py.
References python::core.read_command(), and gui_modules::utils.split().
Referenced by vector_db_select(), and vector_layer_db().
def python.vector.vector_db_select | ( | map, | |
layer = 1 , |
|||
kwargs | |||
) |
Get attribute data of selected vector map layer.
Function returns list of columns and dictionary of values ordered by key column value. Example:
>>> print grass.vector_select('lakes')['values'][3] ['3', '19512.86146', '708.44683', '4', '55652', 'LAKE/POND', '39000', '']
map | map name |
layer | layer number |
kwargs | v.db.select options |
Definition at line 172 of file vector.py.
References python::core.debug(), python::core.read_command(), gui_modules::utils.split(), and vector_db().
def python.vector.vector_history | ( | map | ) |
Set the command history for a vector map to the command used to invoke the script (interface to `v.support').
map | mapname |
Definition at line 136 of file vector.py.
References python::core.run_command().
def python.vector.vector_info_topo | ( | map | ) |
Return information about a vector map (interface to `v.info.
-t'). Example:
>>> grass.vector_info_topo('lakes') {'kernels': 0, 'lines': 0, 'centroids': 15279, 'boundaries': 27764, 'points': 0, 'faces': 0, 'primitives': 43043, 'islands': 7470, 'nodes': 35234, 'map3d': 0, 'areas': 15279}
map | map name |
Definition at line 148 of file vector.py.
References python::core.parse_key_val(), and python::core.read_command().
def python.vector.vector_layer_db | ( | map, | |
layer | |||
) |
Return the database connection details for a vector map layer.
If db connection for given layer is not defined, fatal() is called.
map | map name |
layer | layer number |
Definition at line 79 of file vector.py.
References python::core.fatal(), and vector_db().
def python.vector.vector_what | ( | map, | |
coord, | |||
distance = 0.0 |
|||
) |
Query vector map at given locations.
To query one vector map at one location
print grass.vector_what(map = 'archsites', coord = (595743, 4925281), distance = 250) [{'Category': 8, 'Map': 'archsites', 'Layer': 1, 'Key_column': 'cat', 'Database': '/home/martin/grassdata/spearfish60/PERMANENT/dbf/', 'Mapset': 'PERMANENT', 'Driver': 'dbf', 'Attributes': {'str1': 'No_Name', 'cat': '8'}, 'Table': 'archsites', 'Type': 'Point', 'Id': 8}]
To query one vector map at more locations
for q in grass.vector_what(map = ('archsites', 'roads'), coord = (595743, 4925281), distance = 250): print q['Map'], q['Attributes'] archsites {'str1': 'No_Name', 'cat': '8'} roads {'label': 'interstate', 'cat': '1'}
To query more vector maps at one location
for q in grass.vector_what(map = 'archsites', coord = [(595743, 4925281), (597950, 4918898)], distance = 250): print q['Map'], q['Attributes'] archsites {'str1': 'No_Name', 'cat': '8'} archsites {'str1': 'Bob_Miller', 'cat': '22'}
map | vector map(s) to query given as string or list/tuple |
coord | coordinates of query given as tuple (easting, northing) or list of tuples |
distance | query threshold distance (in map units) |
Definition at line 227 of file vector.py.
References python::core.read_command(), and gui_modules::psmap_dialogs.type.