v.to.pg(1)		      Grass User's Manual		    v.to.pg(1)



NNAAMMEE
       _v_._t_o_._p_g	-  Export areas and lines from an existing vector map to Post-
       gres/PostGIS table. (GRASS-RDBMS Interface Display Program)

SSYYNNOOPPSSIISS
       vv..ttoo..ppgg

       vv..ttoo..ppgg hheellpp

       vv..ttoo..ppgg	[[--ffvvttpp]]  kkeeyy=_n_a_m_e  ttaabb=_n_a_m_ettyyppee=_n_a_m_e   [wwhheerree=_n_a_m_e]   mmaapp=_n_a_m_e
       [ccoolloorr=_n_a_m_e]

AALLTTEERRNNAATTEE
       vv..ttoo..ppgg --ss hheellpp

       vv..ttoo..ppgg ]]--ssffvvpp]] ssqqll_=_f_i_l_e_n_a_m_e mmaapp_=_n_a_m_e ttyyppee=_n_a_m_e [ccoolloorr_=_n_a_m_e]

DDEESSCCRRIIPPTTIIOONN
       _v_._t_o_._p_g exports vectors from an existing vector map based on the unique
       values in a database column (or optionally all vectors  without	refer-
       encing  to  any	existing table, see -t option). Each row returned by a
       user constructed database query will be associated with a  vector  fea-
       ture which may be drawn on the graphics display if X-windows are there.
       The user can control the color of the vector draw by specifying a color
       on the command line.

       As  result, a new Postgres table _t_a_b_l_e___b_n_d or _t_a_b_l_e___a_r_c (or _t_a_b_l_e___m_p_o_l_y
       and _t_a_b_l_e___m_s_t_r_i_n_g for PostGIS) is created to  hold  areas  as  internal
       type "polygon" and lines as "open path", where _t_a_b_l_e is the ttaabb parame-
       ter. Besides these elements in fields called _b_o_u_n_d_a_r_y or  _s_e_g_m_e_n_t,  the
       table  would  also have the category field (named after kkeeyy parameter),
       case number this category occurred in map (as field called 'num'),  and
       an  extra  boolean field 'ex' for 'true' if the polygon is external and
       'f' if it is a hole for _t_a_b_l_e___b_n_d only.

       For PostGIS, the difference is that types of the imported entities  are
       POLYGON (i.e., with "holes" all in one POLYGON) and LINESTRING, respec-
       tively.	The fields are called _g_r_a_s_s___p_o_l_y and _g_r_a_s_s___l_i_n_e. There	is  no
       need  to  define whether a polygon is internal ("hole") or external, in
       this case, therefore there is no field 'ex'.

CCOOMMMMAANNDD LLIINNEE OOPPTTIIOONNSS
   FFllaagg::
       --ff  Fill polygons selected on the query criteria.

       --tt  Export all map vectors without reference to existing table ('where'
	   clause ignored).

       --vv  Verbose mode with statistics on the completion of the insertions.

       --pp  Create and populate PostGIS GEOMETRY format table instead of normal
	   Postgres geometry types.


   PPaarraammeetteerrss::
       kkeeyy==ddaattaabbaasseeccoolluummnnnnaammee
	   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 given
	   on the command line by map=mapname.

       ttaabb==ddaattaabbaasseettaabblleennaammee
	   Table  in the currently selected database containing a column which
	   has values corresponding to vector category values in the map  des-
	   ignated by map=map.

       wwhheerree==SSQQLLwwhheerreeccllaauussee
	   SQL "where" clause which specifies the query criteria to be used in
	   subsetting the database. The field names  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.

       If  the	database  column used as the selection criteria is a character
       field then the associated value must be placed in quotes. To  determine
       the  data types associated with columns in the currently selected data-
       base use the _g_._c_o_l_u_m_n_._p_g command with the _-_v flag.

       Queries which are more complex are best implemented using the  _-_s  flag
       and a prepared SQL file.

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

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

       ttyyppee==aarreeaa,,lliinnee
	   Type of the coverage to export.


AALLTTEERRNNAATTEE CCOOMMMMAANNDD LLIINNEE UUSSAAGGEE
       The alternate command line usage is provided to simplify the process of
       retrieving  information 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 SELECT statement specifying the
       query criteria to retrieve values which correspond to  category	values
       in a GRASS data layer.

   FFllaagg::
       --ss  SQL select statements are input from a prepared file

       --ff  Fill polygons selected on the query criteria

       --vv  Verbose mode with statistics on the completion of the insertions.

       --pp  Create and populate PostGIS GEOMETRY format table instead of normal
	   Postgres geometry types.


   PPaarraammeetteerrss::
       ssqqll==ffiilleennaammee
	   SQL statements specifying well formed selection criteria.

       mmaapp==nnaammee
	   Name of an existing vector map

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

       ttyyppee==aarreeaa,,lliinnee
	   Type of the coverage to export.



       EEXXAAMMPPLLEE::

       11..   _v_._t_o_._p_g  _-_f  _k_e_y_=_r_e_c___i_d  _m_a_p_=_k_u_r_u_m_a___i_d  _t_a_b_=_i_n_f_o___k_u_r_u_m_a  _t_y_p_e_=_a_r_e_a
       _w_h_e_r_e_=_'_t_y_p_e___i_d _>_3_2 _a_n_d _t_y_p_e___i_d _< _3_8_'  _c_o_l_o_r_=_r_e_d



       RReessuulltt:: only polygons with type in 33-37 range would be inserted in ta-
       ble _i_n_f_o___k_u_r_u_m_a___b_n_d and displayed in red color.

       22.. _v_._t_o_._p_g _-_v _-_s _-_f _-_p _s_q_l_=_o_a_k_._s_q_l _m_a_p_=_k_u_r_u_m_a___i_d _t_y_p_e_=_a_r_e_a

       oak.sql is:

       _s_e_l_e_c_t _r_e_c___i_d _f_r_o_m _i_n_f_o___k_u_r_u_m_a _w_h_e_r_e _t_y_p_e___i_d _> _3_2 _a_n_d _t_y_p_e___i_d _<_3_8_;

       RReessuulltt::	this  command  would do the same as in the first example, some
       information printed on screen. However, the result table  would	be  in
       PostGIS format.

BBUUGGSS
       none

NNOOTTEE
       This program requires the Postgres database software.

       The 'total' mode of import (i.e., without referencing to existing table
       _a_n_d to categories count in map) leads to that  field  'num'  in	result
       tables  would  be  incoherent  (simply counts vectors from beginning to
       end).

SSEEEE AALLSSOO
       _g_._s_e_l_e_c_t_._p_g_, _g_._s_t_a_t_s_._p_g_, _g_._t_a_b_l_e_._p_g_, _d_._r_a_s_t_._p_g_, _d_._s_i_t_e_._p_g_, _d_._w_h_a_t_._r_._p_g_,
       _d_._w_h_a_t_._s_._p_g_, _d_._w_h_a_t_._v_._p_g_, _v_._r_e_c_l_a_s_s_._p_g

AAUUTTHHOORR
       Alex Shevlakov (sixote@yahoo.com)



GRASS 5.0							    v.to.pg(1)
