d.vect.pg

NAME

d.vect.pg - Display select vectors from an existing vector map. (GRASS-RDBMS Interface Display Program)

SYNOPSIS

d.vect.pg
d.vect.pg help
d.vect.pg key=name tab=name where=name map=name [color=name] [join=tab,tabkey,pkey]

ALTERNATE

d.vect.pg -s help
d.vect.pg -s pql=filename input=name [color=name]

DESCRIPTION

d.vect.pg displays select vectors from an existing vector map based on the unique values in a database column. Each row returned by a user constructed database query will be associated with a vector feature which is subsequently drawn on the graphics display in the active frame. The user can control the color of the vector draw by specifying a color on the command line.

COMMAND LINE OPTIONS

Parameters:

key=databasecolumnname
Column in table "tab" of the currently selected database containing values corresponding to the vector maps category values. Table is designated on the command line by tab=tablename and vector is designated on the command line by map=mapname.

tab=databasetablename
Table in the currently selected database containing a column which has values corresponding to vector category values in the map designated by map=map.

where=postQUELwhereclause
PostQUEL "where" clause which specifies the query criteria to be used in subsetting the database. The.pgormation specified in the where option must indicate the column(s) to be used, the operators to be used in the evaluation and the values which the data in the column will be evaluated against.
For example, if you want to select only those records where the value for cfcc code is either A21 or A31 the following could be entered:

cfcclookup.code = "A21" or cfcclookup.code = "A31"

To select all cfcclookup.codes the value for cfcclookup.code is of cfcc type A (ie. roads):

cfcclookup.code ~ "A"

To select all cfcclookup.codes except those for roads:

cfcclookup.code !~ "A"

If the database column used as the selection criteria is a character field then the associated value must be placed in double quotes. To determine the data types associated with columns in the currently selected database use the g.column.pg command with the -v flag.

In addition to the operators presented in the examples above a range of relational operators including and, or, etc. are supported. There may be some differences in the relational operators which are supported with different database drivers.

The examples presented above were created using the command line parser. If d.vect.pg is being called from a shell script remember to escape quoted strings. The follwing example presents a component of a shell script used to join two tables and display vector features where the database column cfcclookup.classname is set to "Divided" (eg. all tiger features identified as divided highways).

d.vect.pg key=recordnum tab=feature
where=cfcclookup.classname ~ '"Divided"' map=$1 color=green join=cfcclookup,cfcclookup.cfcc,feature.cat

Queries which are more complex than these are best implemented using the -s flag and a prepared postQUEL file.

map=map
Name of an existing vector map with category values which correspond to values in a specified column in the currently selected database.

color=name
Color to draw vectors in
Colors: red, orange, yellow, green, blue, indigo, violet, magenta, brown, gray, white, black

join=tab,tabkey,pkey
Tab is the table used to develop the current postQUEL query. Tabkey is the database column used to relate.pgormation 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 feature is a table containing column values (recordnum), associated with category values in a GRASS vector file. In addition, assume that cfcclookup.cfcccodes is a table containing attribute data on the transportation network in the same area. In this example recordnum is the column linking feature to the GRASS category file and cfcclookup.cfcc is the column linking cfcclookup with the feature. To specify a query based on attribute values in the table cfcclookup.cfcccodes the join statement would be:

join=cfcclookup,cfcclookup.cfcc,feature.cfcc

Specifying these conditions would insure that all rows from table cfcclookup which satisfy the query criteria would be matched with the corresponding rows in table feature, which are then related to the spatial features in the GRASS data layer via the database column feature.recordnum which is related to 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.pgormation 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 (feature.recordnum)
where cfcclookup.classname ~ "Divided" and cfcclookup.cfcc.= feature.cfcc and feature.recordnum NOTNULL sort by feature.recordnum

Flag:

-s
PostQUEL select statements are input from a prepared file.

Parameters:

pql=filename
PostQUEL statements specifying well formed selection criteria.

input=map
Name of an existing vector map

color=name
Color to draw vectors in
Colors: red, orange, yellow, green, blue, indigo, violet, magenta, brown, gray, white, black

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.rast.pg, d.site.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)