NAME

d.rast.pg - Generate or display a reclass map based on the unique values in a database column. (GRASS-RDBMS Interface Display Program)

SYNOPSIS

d.rast.pg
d.rast.pg help
d.rast.pg key=name tab=name col=name [lab=name] [where=name] input=name [output=name]

ALTERNATE

d.rast.pg -s help
d.rast.pg -s sql=filename input=name [output=name]

DESCRIPTION

d.rast.pg displays a raster image in which each category represents a unique value in a database column. Values are retrieved from the current database based on a user defined SQL SELECT statement. The current database is identified by the GRASS environment variable $PG_DBASE which is set using the g.select.pg GRASS-RDBMS interface tool. The output from this program is a set of GRASS reclass rules which are used to create or display a reclassed raster surface based on the attributes returned from the database and the raster data layer specified as the input map.

COMMAND LINE OPTIONS

Parameters:

key=databasecolumnname
Column corresponding to category values in raster map [input]
tab=databasetablename
Table containing [col]
col=databasecolumnname
Column to base reclass on

where=clause
Where clause for query (ie. where col='paved')

lab=name
Column to use as labels (optional)
input=map
Name of existing raster file
output=map
Name of new reclass map

ALTERNATE COMMAND LINE USAGE

The alternate command line structure is selected using the the [-s] flag on the command line. When using this flag the user must include the name of a text file on the command line as well. This file must include a complete, well formed SQL SELECT statement.
 

Flag:

-s
SQL  statement is input from a prepared file

Parameters:

sql=filename
SQL statement specifying well formed selection criteria.
input=map
Name of an existing raster map
output=map
Name of a new reclass file
EXAMPLE 1:

d.rast.pg input=kur_rast_id output=soils2 tab=info_kuruma key=rec_id col=soils_id lab=soils_info.name where="soils_info.type_id = soils_id"

RESULT:
This example will create a raster map soils2 with a category for each unique value taken from the field "soils_id" from table info_kuruma, with label of value of the column "name" from the table soils_info. The raster map will be a reclassed data layer based on the input raster map kur_rast_id.

EXAMPLE 2:

d.rast.pg -s sql=raster.sql input=kur_rast_id output=soils3

raster.sql:

select rec_id, soils_info.type_id from info_kuruma where soils_info.name ~ 'barren' and soils_info.type_id = soils_id

RESULT:
This example will create a raster map soils3 with a category for each unique value taken from the column "type_id" from the table soils_info, with only 'barren' type. The raster map will be a reclassed data layer based on the input raster map kur_rast_id. Note that there must be two fields in the SELECT statement (these for the old and new values).

In this example, the input map kur_rast_id was prepared by v.to.rast from the vector are map kuruma_id, which is approximately 7,000 polygons with unique ids (corresponding to rec_id field in the table info_kuruma).

BUGS

None known.

NOTE

This program requires the Postgres database software. It uses the GRASS module r.reclass started from inside it.

SEE ALSO

g.column.pg, g.select.pg, g.stats.pg, g.table.pg, d.site.pg, d.vect.pg, d.what.r.pg, d.what.s.pg, d.what.v.pg, r.reclass.pg, r.rescale.pg, v.reclass.pg

AUTHOR

Original Informix SQL-tools: James A. Farley, Wang Song, and W. Fredrick Limp University of Arkansas, CAST

Postgres modifications: Janne Soimasuo, Faculty of Forestry, University of Joensuu, Finland.

Updated to GRASS 5 by Alex Shevlakov (sixote@yahoo.com)