
NAME
v.rast.stats - Calculates univariate statistics from a raster map based on vector polygon map and uploads statistics to new attribute columns.
KEYWORDS
vector, raster, statistics
SYNOPSIS
v.rast.stats
v.rast.stats help
v.rast.stats [-ce] vector=name [layer=integer] raster=name column_prefix=string [percentile=integer] [--verbose] [--quiet]
Flags:
- -c
- Continue if upload column(s) already exist
- -e
- Calculate extended statistics
- --verbose
- Verbose module output
- --quiet
- Quiet module output
Parameters:
- vector=name
- Name of input vector polygon map
- Data source for OGR access
- layer=integer
- Layer number or name
- A single vector map can be connected to multiple database tables. This number determines which table to use. Layer name for OGR access.
- Default: 1
- raster=name
- Name of input raster map to calculate statistics from
- column_prefix=string
- Column prefix for new attribute columns
- percentile=integer
- Percentile to calculate (requires extended statistics flag)
- Options: 0-100
- Default: 90
DESCRIPTION
v.rast.stats - Calculates basic univariate statistics from
a raster map only for the parts covered by the specified vector map.
The vector map will be rasterized according to the raster map resolution.
Then univariate statistics are calculated per vector category (cat) from
the raster map and the results uploaded to the vector map attribute table.
New columns are generated in the attribute table if not already present.
Nine columns are generated (n, min, max, range, mean, stddev, variance,
coeff_var, sum) according to the output of r.univar.
If the -e extended statistics flag is given the 1st quartile,
median, 3rd quartile, and given percentile are also calculated.
NOTES
The module may take a long time to run if the raster region contains a large
number of cells. In this case the --verbose flag may be used to track
progress.
The script stops if a (prefixed) upload column is already present in the
vector map attribute table, unless otherwise instructed with the -c
continue flag. The column prefix will be separated from the statistic name
with an underscore. For example with a prefix of "elev" the sum
column will be named elev_sum.
If a DBF database is being used, note that column names are restricted by the
DBF specification to 10 characters. Therefore it is advised to be economical
in the use of the column prefix when using DBF as any additional characters
will be chopped off.
If a MASK is present, it will be restored after the script finished.
The script changes temporarily to the resolution of the given raster map.
Large amounts of system memory can be used when the -e extended
statistics flag is used with a very large region setting. If the region
is too large the module should display memory allocation errors.
Basic statistics can be calculated using any size input region.
EXAMPLES
Example to upload DEM statistics to vector field patches:
# work on copy of original map:
g.copy vect=fields,myfields
# if needed, zoom to raster map:
g.region rast=elevation.dem -p
# calculate DEM statistics, upload to vector map table:
v.rast.stats myfields raster=elevation.dem colprefix=dem
# verify results:
v.info -c myfields
v.db.select myfields
v.univar myfields column=dem_range type=centroid
SEE ALSO
r.univar,
v.univar,
v.what.rast,
v.what.vect
AUTHOR
Markus Neteler, CEA (EDEN Project)
Last changed: $Date: 2008-08-14 23:16:42 -0700 (Thu, 14 Aug 2008) $
Main index - vector index - Full index
© 2003-2011 GRASS Development Team