NOMBRE
d.vect.pg - Muestra en el monitor gráfico los polígonos
o lineas que cumplen determinadas condiciones
(GRASS-RDBMS Interface Display Program)
USO
d.vect.pg
d.vect.pg help
d.vect.pg key=name tab=name where=name
map=name [color=name] [join=tab,tabkey,pkey]
ALTERNATIVA
d.vect.pg -s help
d.vect.pg -s sql=filename input=name [color=name]
DESCRIPCION
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.
Parámetros:
-
key=databasecolumnname
-
Columna en la tabla (parámetro tab) que contiene los valores
que coinciden con los identificadores en el mapa vectorial (parámetro
map).
-
tab=databasetablename
-
Tabla de la base de datos seleccionada (ver g.column.pg
) que contiene la columna a la que hace referencia el parámetro
key.
-
where=SQLwhereclause
-
Condición que deben cumplir los polígonos o lineas devueltos
por la consulta. Debe cumplir los criterios de la sintaxis SQL y hacer
referenica a cualquier columna de cualquier tabla contenida en la base
de datos seleecionada.
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"
Si se usa una columna consistente en campos de caracteres, el valor
debe encerrarse entre comillas. Para determinar el tipo de datos que contiene
una tabla puede usarse la orden g.column.pg con la opción
-v.
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 SQL 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 SQL 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 SQL 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
-
SQL select statements are input from a prepared file.
Parameters:
-
sql=filename
-
SQL 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
NOTA
This program requires the Postgres database software.
VER
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
AUTOR
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)