Debian Codegraph @

vector/v.external.out/v.external.out.html

raw symbols SCIP
1 <h2>DESCRIPTION</h2>
2
3 <em>v.external.out</em> instructs GRASS to write vector maps in
4 external data format (e.g. ESRI Shapefile, Mapinfo, and others)
5 using <a href="https://gdal.org/">OGR library</a>. PostGIS data can
6 be also written by
7 built-in <a href="https://trac.osgeo.org/grass/wiki/Grass7/VectorLib/PostGISInterface">GRASS-PostGIS
8 data provider</a>.
9
10 <h2>NOTES</h2>
11
12 Number of available output formats (<code>v.external.out -f</code>)
13 depends on OGR installation. 'PostgreSQL' format is presented also
14 when GRASS comes with PostgreSQL support (check for '--with-postgres'
15 in <code>g.version -b</code> output).
16
17 <p>
18 To store geometry and attribute data in PostGIS database ('PostgreSQL'
19 format) GRASS uses built-in <em>GRASS-PostGIS data
20 provider</em>. PostGIS data can be written also by OGR library
21 when <code>GRASS_VECTOR_OGR</code> environmental variable is defined or
22 GRASS is not compiled with PostgreSQL support.
23
24 <p>
25 Creation <b>options</b> refer to the output format specified
26 by <b>format</b> option. See the list of valid creation options
27 at <a href="https://gdal.org/en/stable/drivers/vector/">OGR formats
28 specification page</a>, example
29 for <a href="https://gdal.org/en/stable/drivers/vector/shapefile.html">ESRI
30 Shapefile</a>
31 or <a href="https://gdal.org/en/stable/drivers/vector/pg.html">PostgreSQL/PostGIS</a>
32 format (section &quot;Layer Creation Options&quot;). Options are
33 comma-separated pairs (<code>key=value</code>), the options are
34 case-insensitive,
35 eg. <code>options=&quot;SCHEMA=myschema,FID=cat&quot;</code>.
36
37 <h3>PostgreSQL/PostGIS Creation Options</h3>
38
39 Note that built-in <em>GRASS-PostGIS data provider</em>
40 (<b>format=PostgreSQL</b>) supports different creation <b>options</b>
41 compared to PostgreSQL/PostGIS driver from OGR library:
42 <ul>
43 <li><code>SCHEMA=&lt;name&gt;</code> - name of schema where to create
44 feature tables. If schema doesn't exists, it's automatically created
45 when writing PostGIS data.</li>
46 <li><code>FID=&lt;column&gt;</code> - name of column which will be used as
47 primary key (feature id), default: <code>fid</code></li>
48 <li><code>GEOMETRY_NAME=&lt;column&gt;</code> name of column which will
49 be used for storing geometry data in feature table, default: <code>geom</code></li>
50 <li><code>SPATIAL_INDEX=YES|NO</code> - enable/disable spatial index on geometry column, default: YES</li>
51 <li><code>PRIMARY_KEY=YES|NO</code> - enable/disable primary key on FID column, default: YES</li>
52 <li><code>SRID=&lt;value&gt;</code> - spatial reference identifier,
53 default: not defined</li>
54 <li><code>TOPOLOGY=YES|NO</code> - enable/disable
55 native <a href="https://grasswiki.osgeo.org/wiki/PostGIS_Topology">PostGIS
56 topology</a>, default: NO</li>
57 </ul>
58
59 Options relevant only to topological output (<code>TOPOLOGY=YES</code>):
60
61 <ul>
62 <li><code>TOPOSCHEMA_NAME=&lt;schema name&gt;</code> - name of PostGIS
63 Topology schema (relevant only for <code>TOPOLOGY=YES</code>),
64 default: <code>topo_&lt;input&gt;</code></li>
65 <li><code>TOPOGEOM_NAME=&lt;column&gt;</code> - name of column which
66 will be used for storing topogeometry data in feature table,
67 default: <code>topo</code></li>
68 <li><code>TOPO_TOLERANCE=&lt;value&gt;</code> - tolerance for PostGIS
69 Topology schema,
70 see <a href="https://postgis.net/docs/CreateTopology.html">CreateTopology</a>
71 function for details, default: <code>0</code></li>
72 <li><code>TOPO_GEO_ONLY=YES|NO</code> - store in PostGIS Topology schema
73 only data relevant to Topo-Geo data model, default: <code>NO</code></li>
74 <li><code>SIMPLE_FEATURE=YES|NO</code> - build simple features geometry
75 in <code>GEOMETRY_NAME</code> column from topogeometry data, default:
76 NO</li>
77 </ul>
78
79 Note that topological output requires <b>PostGIS version 2 or later</b>.
80
81 <h2>EXAMPLES</h2>
82
83 <h3>ESRI Shapefile</h3>
84
85 <em>v.external.out</em> can be used along with
86 <em><a href="v.external.html">v.external</a></em> to process external
87 geodata in GRASS while writing out the results directly eg. in ESRI
88 Shapefile format:
89
90 <div class="code"><pre>
91 # register Shapefile in GRASS mapset:
92 v.external input=/path/to/shapefiles layer=cities
93
94 # define output directory for GRASS calculation results:
95 v.external.out output=$HOME/gisoutput
96
97 # do something (here: spatial query), write output directly as Shapefile
98 v.select ainput=cities atype=point binput=forests btype=area operator=within output=fcities
99 </pre></div>
100
101 Current settings can be printed using <b>-p</b> or <b>-g</b> flag.
102
103 <div class="code"><pre>
104 v.external.out -p
105
106 output: /path/to/home/gisoutput
107 format: ESRI Shapefile
108 </pre></div>
109
110 <h3>PostGIS (simple features)</h3>
111
112 PostGIS data can be accessed directly using <em>GRASS-PostGIS data
113 provider</em> (GRASS must be compiled with PostgreSQL support).
114
115 <div class="code"><pre>
116 # register PostGIS table in GRASS mapset:
117 v.external output=PG:dbname=gisdb layer=cities
118
119 # define output PostGIS database for GRASS calculation results stored as simple features:
120 v.external.out output=PG:dbname=gisdb format=PostgreSQL
121
122 # do some processing...
123 </pre></div>
124
125 <i>Note:</i> If the environment variable <code>GRASS_VECTOR_OGR</code>
126 is defined, or GRASS is compiled without PostgreSQL support then GRASS
127 will use PostgreSQL driver from OGR library for reading and writing
128 PostGIS data.
129
130 <h3>PostGIS Topology</h3>
131
132 <div class="code"><pre>
133 # define output PostGIS database for GRASS calculation results stored as topological elements:
134 v.external.out output=PG:dbname=gisdb format=PostgreSQL options=topology=YES
135
136 # do some processing...
137 </pre></div>
138
139 <i>Note:</i> PostGIS topological access is supported only in
140 built-in <em>GRASS-PostGIS data provider</em>.
141
142 <h3>GRASS native format</h3>
143
144 To restore original settings, ie. use the GRASS native format, type:
145
146 <div class="code"><pre>
147 v.external.out -r
148 </pre></div>
149
150 <h3>Restore settings</h3>
151
152 Current settings can be stored to file by specifying <b>output</b> option.
153
154 <div class="code"><pre>
155 # define output PostGIS database for GRASS calculation with
156 # results stored as topological elements:
157 v.external.out output=PG:dbname=gisdb format=PostgreSQL \
158 options=topology=YES savesettings=gisdb_topo.txt
159
160 # ... and do some processing in PostGIS Topology
161 </pre></div>
162
163 Back to native format:
164
165 <div class="code"><pre>
166 v.external.out -r
167
168 # do some processing in native format
169 </pre></div>
170
171 Restore previous settings from &quot;gisdb_topo.txt&quot; file by
172 specifying <b>loadsettings</b> option.
173
174 <div class="code"><pre>
175 v.external.out loadsettings=gisdb_topo.txt
176
177 # ... and do some processing in PostGIS Topology
178 </pre></div>
179
180 <h2>REFERENCES</h2>
181
182 <ul>
183 <li><a href="https://trac.osgeo.org/grass/wiki/Grass7/VectorLib/OGRInterface">GRASS-OGR data provider</a></li>
184 <li><a href="https://gdal.org/en/stable/api/">OGR vector library C API</a> documentation</li>
185 <li><a href="https://trac.osgeo.org/grass/wiki/Grass7/VectorLib/PostGISInterface">GRASS-PostGIS data provider</a></li>
186 <li><a href="https://www.postgresql.org/docs/9.1/static/libpq.html">libpq - C Library</a></li>
187 </ul>
188
189 <h2>SEE ALSO</h2>
190
191 <em>
192 <a href="v.external.html">v.external</a>,
193 <a href="v.in.ogr.html">v.in.ogr</a>,
194 <a href="v.out.ogr.html">v.out.ogr</a>,
195 <a href="v.out.postgis.html">v.out.postgis</a>
196 </em>
197
198 <p>
199 See
200 also GRASS <a href="https://grasswiki.osgeo.org/wiki/Working_with_external_data_in_GRASS_7">user wiki page</a> for more examples.
201
202 <h2>AUTHOR</h2>
203
204 Martin Landa, Czech Technical University in Prague, Czech Republic
205 (development supported by Fondazione Edmund Mach and Comune di Trento, Italy)