NAME

d.what.v.pg - Report database attributes associated with vector features.
 

SYNOPSIS:

d.what.v.pg [-f] map=name tab=name col=name [color=name]
   [fillcolor=name] [hv=name]

d.what.v.pg [-sf] sql=file map=name [color=name] [fillcolor=name]
   [hv=name]
 

DESCRIPTION

Flags:
-s   Use [-s] for SQL command file input.
-f   Fill polygons?

Parameters:

sql

Name of the SQL command file

map
Vector map to run query on

tab
Postgres table with categories

col
Column with categories from this table

color
Selected lines color
default: yellow

fillcolor
Selected areas color (for fill)
options: red,orange,yellow,green,blue,indigo,white,black,brown, magenta,aqua,gray,grey
default: gray

hv
Type of database output - [h/v]
default: v

 

 

tab is Postgres table containing column linked to vector attribute values, col - column associated with vector attribute values, map is name of an existing vector map with attribute values linked to the cur­ rently selected database.

Reports database attributes from the currently selected database which are associated with specific vector features identified using the mouse. The currently selected database is identified by the GRASS environment variable $PG_DBASE which is set using the g.select.pg GRASS-RDBMS interface tool. If this environment variable is not set the program terminates with a message to the user. If the alternate form of this command is selected with the -s flag the user has greater control over the manner in which the attribute information is displayed.

d.what.v.pg is used to query lines/areas with mouse. Like d.what.vect, it lists attributes and optionally fills queried areas (like v.area). It may be used for the UPDATE command in Postgres through the input SQL file (see Example 2). The idea is to prepare an arbitrary algorithm, code it in SQL, and then update DB with clicking on chosen polys/lines. You may consider this as piping  through various filters anything you select on screen.

The database information can be optionally output as comma-sepatated list (horizontal) which is convenient for feeding it to other programs like table editors.
 

EXAMPLE:

1. d.what.v.pg -s sql=census.sql map=census

and census.sql is:

select slope, type_id from info_kuruma where rec_id = ?

Result: only two fields information is displayed on screen when the mouse is clicked upon the vector object.

2. d.what.v.pg -s sql=process.sql map=census

process.sql is:

update census_info set type_good = '1' where rec_id = ? and info_kuruma.type_id = 35 and info_kuruma.rec_id = rec_id;

Result: this would only change field of the census_info table for the clicked polygon or line,
if the corresponding type taken from info_kuruma table is equal to 35 (the last limitation is a filter for any polygon/line picked from the map with mouse) .

Flags: SQL select statements are input from a prepared file.

Parameters: SQL statements specifying well formed selection criteria. Name of an existing vector map.

BUGS

1. As of now, d.vect.pg and d.what.v.pg both use R_polygon_abs() for
filling polys, which seems to ignore islands. So you'd rather say to no fill the
areas.

2. Tcl-Tk modules require input "where" clause restricted to one rule typed without "whitespaces",
(unlike terminal input where number of subclause is not limited).

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.vect.pg, d.what.r.pg, d.what.s.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)