d.rast.pg

NAME

d.rast.pg - Generate and 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 input=name [output=name] [join=tab,tabkey,pkey]

ALTERNATE

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

DESCRIPTION

d.rast.pg displays a raster image in which each category represents a uniques value in a database column. Values are retrieved from the current database based on a user defined postQUEL retrieve statement. The current database is identified by the GRASS environment variable $PGDBASE which is set using the g.select.pg GRASS-RDBMS interface tool. If no join parameters are specified by the user a column in the database table directly linked to the GRASS raster structure via the category value must be used. The output from this program is a set of GRASS reclass rules which are used to create and 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

input=map
Name of existing raster file

output=map
Name of new reclass map

join=tab,tabkey,pkey
Tab is the table used to develop the current postQUEL query. Tabkey is the database column used to relate information in this table with data in the table linked to the GRASS category file. Pkey is the associated column in the table linked to the GRASS category file which is related to tabkey in the current table.

For instance, assume that secosoilcats is a table containing column values associated with category values in a the GRASS raster file soils. In addition, assume that compyld is a table containing attribute data on the crop production capacity in the same area (cropname). In this example secosoilcats is the table associated with the GRASS raster map and grasscats is the column linking secosoilcats to the GRASS category file, the table compyld contains the attribute information to base the query/reclass on and it is linked to secosoilcats via the common column muid. To specify a query based on attribute values in the table compyld:

d.rast.pg key=grasscat tab=secosoilcats col=cropname input=soils join=compyld,compyld.muid,secosoilcats.muid

Specifying these conditions would insure that all rows from table compyld which satisfy the query criteria would be matched with the corresponding rows in table secosoilcats, which are then related to the spatial features in the GRASS data layer via the GRASS category values.

This syntax is adequate to accomplish 2 table joins. However, if the query demands joins between more than 2 tables it is advisable to use the -s option [see Alternate Command Line Usage] to read a user prepared query, complete with join requirements, from a file.

ALTERNATE COMMAND LINE USAGE

The alternate command line usage is provided to simplify the process of retrieving information from more than one table in the query criteria. 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 postQUEL retrieve statement specifying the query criteria and all relevant JOINS needed to retrieve values which correspond to category values in a GRASS data layer.

The user must also specify the name of the GRASS data layer containing these category values on the command line. The following example illustrates the syntax which must be used in constructing a retrieve statement for use with the -s flag.

retrieve unique (cfccatts.tlid,main.cfcode)
where cfcc.majfea="roads" and cfcc.minfea="county roads" and cfcc.cfcode=main.cfcode and main.cfcode NOTNULL sort by main.cfcode using

Flag:

-s
PostQUEL retrieve statements are input from a prepared file

Parameters:

pql=filename
PostQUEL statements specifying well formed selection criteria.
input=map
Name of an existing raster map
output=map
Name of a new reclass file
EXAMPLE (two table join)

d.rast.pg -s pql=statsgo.pql input=secosoils

statsgo.pql:
retrieve unique secosoilcats.grasscat,compyld.cropname)
where compyld.muid = secosoilcats.muid and cropname NOTNULL sort by cropname

RESULT:
This example will display a raster surface with a category for each unique value of the column "cropname" from the table compyld. The raster surface will be a reclassed data layer based on the input raster map secosoils.

BUGS

None known.

NOTE

This program requires the Postgres database software.

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)