d.site.pg

NAME

d.site.pg - Display select sites from a database query. (GRASS-RDBMS Interface Display Program)

SYNOPSIS

d.site.pg
d.site.pg help
d.site.pg tab=name coords=X-column,Y-column where=name [map=name] [plot=color,icon,size] [join=tab,tabkey,pkey]

ALTERNATE

d.site.pg -s help
d.site.pg -s pql=filename [map=name][plot=color,icon,size]

DESCRIPTION

d.site.pg displays select point location information returned from a database query. The site locations returned from the database query are displayed as icons in the active frame. The user controls the color, size and icon used in the graphic output. At the users option a site list of the database output is generated and placed in the current mapset/location.

COMMAND LINE OPTIONS

Parameters:

tab=databasetablename
Table containing X, Y coordinate values.

coords=databasecolumnnames
Columns containing x,y coordinate values.

where=postQUELwhereclause
postQUEL "where" clause which specifies the query criteria to be used in subsetting the database. The information 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 from the table well where the value for depth is either 58 or 75 the following could be entered:

well.depth = 58 or well.depth = 75

To select all wells in an area where the value for well is between 50 and 120:

well.depth > 50 and well.depth < 120

To select all wells of depth greater than 75 where the value for owner is not equal to SMITH:

well.depth > 75 and well.owner != "SMITH"

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.site.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 ad.pgo is set to "NONE".

d.site.pg tab=well coords=utme,utmy
where=ad.info='"NONE"'map=$1 plot=green,plus,2 join=rds2,rds2.cat2,well.cat

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

map=list
Name of sites list to output

plot=color,icon,size
Colors: red, orange, yellow, green, blue, indigo, violet, magenta, brown, gray, white, black
Icon: diamond, box, plus, x
Size: 1-9
Default: gray, x, 3

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 well is a table containing X,Y coordinate values and that wellowners is a table containing ownership.pgormation associated with well logs. To base a query on site location which would return attribute data on ownership and locational.pgormation in the table well the following join would be needed on the command line:

tab = well
join=wellowners,wellowners.wellid,well.wellid

The column wellid is common to both the well and the wellowners table. Because of this attribute data from both tables will be returned if the coordinates registered by the mouse return a record from the table well within a radius specified by the distance parameter on the command line. Specifying these conditions would insure that all rows from table roads which satisfy the query criteria would be matched with the corresponding rows in table main, 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 require­ments, 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 (utm.utme, utm.utmn)
where utm.mlra="116A" and utm.hydunit=11110103 and utm.utme > 0 and utm.utmn > 0 sort by utme, utmn

Flag:

-s
postQUEL retrieve statements are input from a prepared file.

Parameters:

pql=filename
PostQUEL statements specifying well formed selection criteria

map=list
Name of sites list to output

plot=color,icon,size
Colors: red, orange, yellow, green, blue, indigo, violet, magenta, brown, gray, white, black
Icon: diamond, box, plus, x
Size: 1-9
Default: gray, x, 3

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.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)