v.histogram
Draws the histogram of values in a vector attribute column
v.histogram map=name [layer=string] column=name [where=sql_query] plot_output=name [bins=integer] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
v.histogram map=name column=name plot_output=-
grass.script.run_command("v.histogram", map, layer="1", column, where=None, plot_output="-", bins=30, overwrite=False, verbose=False, quiet=False, superquiet=False)
Example:
gs.run_command("v.histogram", map="name", column="name", plot_output="-")
Parameters
map=name [required]
Name of vector map
Or data source for direct OGR access
layer=string
Layer number or name
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Default: 1
column=name [required]
Attribute column to create histogram from
where=sql_query
WHERE conditions of SQL statement without 'where' keyword
Example: income < 1000 and population >= 10000
plot_output=name [required]
Name for graphic output file for plot (extension decides format, - for screen)
Name for output file
Default: -
bins=integer
Number of bins in histogram
Default: 30
--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
map : str, required
Name of vector map
Or data source for direct OGR access
Used as: input, vector, name
layer : str, optional
Layer number or name
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Used as: input, layer
Default: 1
column : str, required
Attribute column to create histogram from
Used as: input, dbcolumn, name
where : str, optional
WHERE conditions of SQL statement without 'where' keyword
Example: income < 1000 and population >= 10000
Used as: input, sql_query, sql_query
plot_output : str, required
Name for graphic output file for plot (extension decides format, - for screen)
Name for output file
Used as: output, file, name
Default: -
bins : int, optional
Number of bins in histogram
Default: 30
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.histogram draws a histogram of the values in a vector map attribute column. Users can use the where option to only select a subset of the attribute table and can determine the number of bins (bars) used for the histogram. The plot_output parameter determines whether the result is displayed on screen (default) or exported to a graphics file.
NOTE
This is a quick and dirty solution using basic matplotlib. In future, this should be integrated into the g.gui, possibly together with the raster histogram tool.
EXAMPLE
Show the histogram of median age values in the census block map:
v.histogram map=censusblk_swwake column=MEDIAN_AGE where="TOTAL_POP>0"
Histogram of median age values in census blocks
AUTHOR
Moritz Lennert
SOURCE CODE
Available at: v.histogram source code
(history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819