NOMBRE

d.site.pg - Muestra los sites seleccionados por una consulta a base de datos.
(GRASS-RDBMS Interface Display Program)

USO

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

ALTERNATIVO

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

DESCRIPCION

Los sites devueltos de la base de datos se muestran como iconos cuyas características (color, tipo de icono y tamaño) se establecen en el parámetro plot=. Si se especifica el parámetro map= se creará una nueva lista de sitios cuya categoría será la que se invocó con el parámetro cats=

Parametros:

tab=databasetablename
Tabla que contiene dos columnas con las coordenadas X e Y
coordx=databasecolumnname   coordy=databasecolumnname
Columnas que contienen las coordenadas X e Y
where=SQLwhereclause
sentencia SQL para establecer los criterios de búsqueda de la consulta:
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 SQL 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 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 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.

Esta sintaxis sólo resulta adecuada si se está trabajando con consultas simples, para llevar a cabo consultas m complejas es más eficiente el modo alternativo (opción -s).

ALTERNATE COMMAND LINE USAGE

Flag:

-s
La consulta se hace mediante una orden SQL almacenada en un fichero.

Parametros:

sql=filename
Fichero SQL especificando los criterios de selección
map=list
Nombre del fichero de sites que va a producirse
plot=color,icon,size
Colores: red, orange, yellow, green, blue, indigo, violet, magenta, brown, gray, white, black
Iconos: diamond, box, plus, x
Tamaños: 1-9
Por defecto: gray, x, 3
El fichero SQL contiene una orden SELECT que debe solicitar en primer lugar las columnas que contengan las coordenadas X e Y de los registros que cumplan las condiciones más aquellas otras que se deseen. En el fichero resultante

Ejemplo:

select utm.utme, utm.utmn where utm.mlra="116A" and utm.hydunit=11110103 and utm.utme > 0 and utm.utmn > 0 sort by utme, utmn

NOTA

Requiere Postgres como motor de búsqueda

VER

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

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)