v.neighborhoodmatrix
Exports the neighborhood matrix of polygons in a vector map
v.neighborhoodmatrix [-b] input=name [player=integer] [idcolumn=name] [output=name] [separator=character] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
v.neighborhoodmatrix input=name
grass.script.run_command("v.neighborhoodmatrix", input, player=1, idcolumn=None, output=None, separator="pipe", flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)
Example:
gs.run_command("v.neighborhoodmatrix", input="name")
Parameters
input=name [required]
Name of input vector map
Or data source for direct OGR access
player=integer
Layer in map where polygons are to be found
Default: 1
idcolumn=name
Name of column containing polygon ids
output=name
Name for output file (if omitted or "-" output to stdout)
separator=character
Field separator
Special characters: pipe, comma, space, tab, newline
Default: pipe
-b
create bidirectional matrix (same neighborhood relation repeated twice)
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
input : str, required
Name of input vector map
Or data source for direct OGR access
Used as: input, vector, name
player : int, optional
Layer in map where polygons are to be found
Default: 1
idcolumn : str, optional
Name of column containing polygon ids
Used as: input, dbcolumn, name
output : str, optional
Name for output file (if omitted or "-" output to stdout)
Used as: output, file, name
separator : str, optional
Field separator
Special characters: pipe, comma, space, tab, newline
Used as: input, separator, character
Default: pipe
flags : str, optional
Allowed values: b
b
create bidirectional matrix (same neighborhood relation repeated twice)
overwrite: bool, optional
Allow output files to overwrite existing files
Default: False
verbose: bool, optional
Verbose module output
Default: False
quiet: bool, optional
Quiet module output
Default: False
superquiet: bool, optional
Very quiet module output
Default: False
DESCRIPTION
v.neighborhoodmatrix identifies all adjacency relations between polygons in a vector map and exports these as a 2xn matrix where n is the number of neighborhood relations with each relation only listed in one direction (i.e. if a is neighbor of b, the list will contain a,b, but not b,a) unless the b flag is specified. By default, neighbors are identified by the category numbers. Using the idcolumn parameter the user can define a column to use as identifier of the polygons. If a path to an output file is specified, the matrix will be written to that file, otherwise it will be sent to standard output.
NOTES
Currently the module assumes that the layer above the layer containing the polygons is empty and available for adding categories to boundaries. The module uses v.to.db to determine neighborhood relations.
EXAMPLE
Send the neighborhood matrix of the census tracts of the North Carolina dataset to standard output identifying each tract by its category value:
v.neighborhoodmatrix in=census_wake2000
Idem, but identifying each tract by its STFID code and sending the output to a file:
v.neighborhoodmatrix in=census_wake2000 idcolumn=STFID output=census_neighbors.csv
SEE ALSO
AUTHOR
Moritz Lennert
SOURCE CODE
Available at: v.neighborhoodmatrix source code
(history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819