Note: This document is for an older version of GRASS GIS that has been discontinued. You should upgrade, and read the current manual page.

GRASS logo

NAME

r.zonal.classes - Calculates zonal classes proportion describing raster areas's composition, e.g., in terms of land-cover classes.

KEYWORDS

raster, statistics, zonal statistics

SYNOPSIS

r.zonal.classes
r.zonal.classes --help
r.zonal.classes [-rcnpl] zone_map=name raster=name statistics=string[,string,...] [prefix=string] [decimals=integer] [classes_list=string] [csvfile=name] [separator=character] [vectormap=name] [--overwrite] [--help] [--verbose] [--quiet] [--ui]

Flags:

-r
Adjust region to input map
-c
Force check of input's layer type
-n
Consider null values in the calculations
-p
Proportions as percentages instead of zone's area ratio
-l
Compute statistics only for the classes provided in 'classes_list' parameter
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--ui
Force launching GUI dialog

Parameters:

zone_map=name [required]
Name for input raster map with areas
Raster map with areas (all pixels of an area have same id), such as the output of r.clump
raster=name [required]
Name of input categorical raster maps for statistics
statistics=string[,string,...] [required]
Statistics to calculate for each input raster map
Options: proportion, mode
Default: proportion,mode
prefix=string
Prefix for statistics name
decimals=integer
Number of decimals for proportion numbers
Default: 5
classes_list=string
List of classes to be considered in the calculation, e.g. '21,34,35,56'
csvfile=name
Name for output CSV file containing statistics
separator=character
Field separator
Special characters: pipe, comma, space, tab, newline
Default: pipe
vectormap=name
Name for optional vector output map with statistics as attributes

Table of contents

DESCRIPTION

r.zonal.classes computes class proportions and majority class (mode) of a "cover layer" (provided via the raster parameter) - e.g. a land cover map - according to how it intersects with areas/objects in a "base layer" (provided via the zone_map parameter). Areas are defined by adjacent pixels with the same value, such as those obtained with r.clump or i.segment.

This function is similar to r.stats.zonal, but is intended to be used on a categorical raster with integer values (CELL type) instead of floating point as in r.stats.zonal.

NOTES

The user can choose between output in the form of a vector map of the areas contained in the "base layer" with the statistics of the "cover layer" stored in the attribute table (the name of the vector layer should be provided via the vectormap parameter) and/or in the form of a CSV text file (the path to the file should be provided via the csvfile parameter).

By default:

EXAMPLES

On North Carolina sample dataset:
# Define region
g.region raster=zipcodes

# Get majority class and class proportion of 'landuse96_28m'
# for each zone/object in 'zipcode' layer
r.zonal.classes zone_map=zipcodes raster=landuse96_28m csvfile=output.csv \
  vectormap=vect_output

# Display attributes table
v.db.select map=vect_output

cat	mode	prop_0	prop_1	 ...	prop_21
27511	18	0.00009	0.11286	 ...	0.00000
27513	15	0.00000	0.06098	 ...	0.00000
27518	15	0.00000	0.06455	 ...	0.00000
27529	15	0.00000	0.24149	 ...	0.00000
...	...	...	...	 ...	...

# Get only class proportion (not the mode), add prefix on columns and
# return proportion as percentages instead of the zone's area ratio
r.zonal.classes zone_map=zipcodes raster=landuse96_28m csvfile=output.csv \
  vectormap=vect_output prefix=lu statistics=proportion -p

# Display attributes table
v.db.select map=vect_output

cat	lu_prop_0	lu_prop_1	...	lu_prop_21
27511	0.00851		11.28639	...	0.00000
27513	0.00000		6.09839		...	0.00000
27518	0.00000		6.45485		...	0.00000
27529	0.00000		24.14926	...	0.00000
...	...		...		...	 ...

# Ensure that a column is created for class '1234' even if it doesn't exist
# under the current computational region
r.zonal.classes zone_map=zipcodes raster=landuse96_28m csvfile=output.csv \
  vectormap=vect_output prefix=lu classes_list='1234'

# Display attributes table
v.db.select map=vect_output

cat	lu_mode	lu_prop_0	...	lu_prop_21	lu_prop_1234
27511	18	0.00009		...	0.00000		0.00000
27513	15	0.00000		...	0.00000		0.00000
27518	15	0.00000		...	0.00000		0.00000
...	...	...		...	 ...		...

# Output only the proportion columns for classes '4,12,1234'
r.zonal.classes zone_map=zipcodes raster=landuse96_28m csvfile=output.csv \
  vectormap=vect_output classes_list='4,12,1234' -l

# Display attributes table
v.db.select map=vect_output

cat	mode	prop_4		prop_12	prop_1234
27511	18	0.02310		0.00000	0.00000
27513	15	0.02888		0.00000	0.00000
27518	15	0.06291		0.00000	0.00000
27529	15	0.02579		0.00000	0.00000
...	...	...		...	 ...

Acknowledgement

This work was funded by the Belgian Federal Science Policy Office (BELSPO) (Research Program for Earth Observation STEREO III, contract SR/00/304) as part of the MAUPP project and by the department of Geomatics of the Walloon region as part of the WALOUS project.

SEE ALSO

r.stats.zonal, r.univar, v.rast.stats, i.segment.stats (Addon),

AUTHOR

Tais GRIPPA - Universite Libre de Bruxelles. ANAGEO Lab.

SOURCE CODE

Available at: r.zonal.classes source code (history)

Latest change: Monday Nov 11 18:04:48 2024 in commit: 59e289fdb093de6dd98d5827973e41128196887d


Main index | Raster index | Topics index | Keywords index | Graphical index | Full index

© 2003-2024 GRASS Development Team, GRASS GIS 8.3.3dev Reference Manual