1ogr2ogr(1)                  General Commands Manual                 ogr2ogr(1)
2
3
4

NAME

6       ogr2ogrConverts simple features data between file formats.
7

SYNOPSIS

9       Usage: ogr2ogr [--help-general] [-skipfailures] [-append] [-update]
10                      [-select field_list] [-where restricted_where|@filename]
11                      [-progress] [-sql <sql statement>|@filename] [-dialect dialect]
12                      [-preserve_fid] [-fid FID] [-limit nb_features]
13                      [-spat xmin ymin xmax ymax] [-spat_srs srs_def] [-geomfield field]
14                      [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def]
15                      [-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...]
16                      dst_datasource_name src_datasource_name
17                      [-lco NAME=VALUE] [-nln name]
18                      [-nlt type|PROMOTE_TO_MULTI|CONVERT_TO_LINEAR|CONVERT_TO_CURVE]
19                      [-dim XY|XYZ|XYM|XYZM|2|3|layer_dim] [layer [layer ...]]
20
21       Advanced options :
22                      [-gt n]
23                      [[-oo NAME=VALUE] ...] [[-doo NAME=VALUE] ...]
24                      [-clipsrc [xmin ymin xmax ymax]|WKT|datasource|spat_extent]
25                      [-clipsrcsql sql_statement] [-clipsrclayer layer]
26                      [-clipsrcwhere expression]
27                      [-clipdst [xmin ymin xmax ymax]|WKT|datasource]
28                      [-clipdstsql sql_statement] [-clipdstlayer layer]
29                      [-clipdstwhere expression]
30                      [-wrapdateline] [-datelineoffset val]
31                      [[-simplify tolerance] | [-segmentize max_dist]]
32                      [-addfields] [-unsetFid]
33                      [-relaxedFieldNameMatch] [-forceNullable] [-unsetDefault]
34                      [-fieldTypeToString All|(type1[,type2]*)] [-unsetFieldWidth]
35                      [-mapFieldType type1|All=type2[,type3=type4]*]
36                      [-fieldmap identity | index1[,index2]*]
37                      [-splitlistfields] [-maxsubfields val]
38                      [-explodecollections] [-zfield field_name]
39                      [-gcp pixel line easting northing [elevation]]* [-order n | -tps]
40                      [-nomd] [-mo "META-TAG=VALUE"]* [-noNativeData].fi
41

DESCRIPTION

43       This program can be used to convert simple features data between file
44       formats performing various operations during the process such as
45       spatial or attribute selections, reducing the set of attributes,
46       setting the output coordinate system or even reprojecting the features
47       during translation.
48
49        -f format_name:
50           output file format name, some possible values are:
51
52            -f "ESRI Shapefile"
53            -f "TIGER"
54            -f "MapInfo File"
55            -f "GML"
56            -f "PostgreSQL"
57
58        Starting with GDAL 2.3, if not specified, the format is guessed from
59       the extension (previously was ESRI Shapefile).
60
61       -append:
62           Append to existing layer instead of creating new
63
64       -overwrite:
65           Delete the output layer and recreate it empty
66
67       -update:
68           Open existing output datasource in update mode rather than trying
69           to create a new one
70
71       -select field_list:
72           Comma-delimited list of fields from input layer to copy to the new
73           layer. A field is skipped if mentioned previously in the list even
74           if the input layer has duplicate field names. (Defaults to all; any
75           field is skipped if a subsequent field with same name is found.)
76           Starting with OGR 1.11, geometry fields can also be specified in
77           the list.
78
79       -progress:
80           (starting with GDAL 1.7.0) Display progress on terminal. Only works
81           if input layers have the 'fast feature count' capability.
82
83       -sql sql_statement:
84           SQL statement to execute. The resulting table/layer will be saved
85           to the output. Starting with GDAL 2.1, the @filename syntax can be
86           used to indicate that the content is in the pointed filename.
87
88       -dialect dialect:
89           SQL dialect. In some cases can be used to use (unoptimized) OGR SQL
90           instead of the native SQL of an RDBMS by passing OGRSQL. Starting
91           with GDAL 1.10, the 'SQLITE' dialect can also be used with any
92           datasource.
93
94       -where restricted_where:
95           Attribute query (like SQL WHERE). Starting with GDAL 2.1, the
96           @filename syntax can be used to indicate that the content is in the
97           pointed filename.
98
99       -skipfailures:
100           Continue after a failure, skipping the failed feature.
101
102       -spat xmin ymin xmax ymax:
103           spatial query extents, in the SRS of the source layer(s) (or the
104           one specified with -spat_srs). Only features whose geometry
105           intersects the extents will be selected. The geometries will not be
106           clipped unless -clipsrc is specified
107
108       -spat_srs srs_def:
109           (OGR >= 2.0) Override spatial filter SRS.
110
111       -geomfield field:
112           (OGR >= 1.11) Name of the geometry field on which the spatial
113           filter operates on.
114
115       -dsco NAME=VALUE:
116           Dataset creation option (format specific)
117
118       -lco NAME=VALUE:
119           Layer creation option (format specific)
120
121       -nln name:
122           Assign an alternate name to the new layer
123
124       -nlt type:
125           Define the geometry type for the created layer. One of NONE,
126           GEOMETRY, POINT, LINESTRING, POLYGON, GEOMETRYCOLLECTION,
127           MULTIPOINT, MULTIPOLYGON or MULTILINESTRING. And CIRCULARSTRING,
128           COMPOUNDCURVE, CURVEPOLYGON, MULTICURVE and MULTISURFACE for GDAL
129           2.0 non-linear geometry types. Add 'Z', 'M', or 'ZM' to the name to
130           get coordinates with elevation, measure, or elevation and measure.
131           Starting with GDAL 1.10, PROMOTE_TO_MULTI can be used to
132           automatically promote layers that mix polygon or multipolygons to
133           multipolygons, and layers that mix linestrings or multilinestrings
134           to multilinestrings. Can be useful when converting shapefiles to
135           PostGIS and other target drivers that implement strict checks for
136           geometry types. Starting with GDAL 2.0, CONVERT_TO_LINEAR can be
137           used to to convert non-linear geometries types into linear
138           geometries by approximating them, and CONVERT_TO_CURVE to promote a
139           non-linear type to its generalized curve type (POLYGON to
140           CURVEPOLYGON, MULTIPOLYGON to MULTISURFACE, LINESTRING to
141           COMPOUNDCURVE, MULTILINESTRING to MULTICURVE). Starting with 2.1
142           the type can be defined as measured ('25D' remains as an alias for
143           single 'Z'). Some forced geometry conversions may result in invalid
144           geometries, for example when forcing conversion of multi-part
145           multipolygons with -nlt POLYGON, the resulting polygon will break
146           the Simple Features rules.
147
148       -dim val:
149           (starting with GDAL 1.10) Force the coordinate dimension to val
150           (valid values are XY, XYZ, XYM, and XYZM - for backwards
151           compatibility 2 is an alias for XY and 3 is an alias for XYZ). This
152           affects both the layer geometry type, and feature geometries.
153           Starting with GDAL 1.11, the value can be set to 'layer_dim' to
154           instruct feature geometries to be promoted to the coordinate
155           dimension declared by the layer. Support for M was added in GDAL
156           2.1
157
158       -a_srs srs_def:
159           Assign an output SRS
160
161       -t_srs srs_def:
162           Reproject/transform to this SRS on output
163
164       -s_srs srs_def:
165           Override source SRS
166
167       -preserve_fid:
168           Use the FID of the source features instead of letting the output
169           driver to automatically assign a new one (when it needs to assign a
170           FID. Some formats, like GeoJSON, have optional FID) Note: starting
171           with GDAL 2.0, if not in append mode, this behaviour becomes the
172           default if the output driver has a FID layer creation option. In
173           which case the name of the source FID column will be used and
174           source feature IDs will be attempted to be preserved. This
175           behaviour can be disabled by setting -unsetFid
176
177       -fid fid:
178           If provided, only the feature with this feature id will be
179           reported. Operates exclusive of the spatial or attribute queries.
180           Note: if you want to select several features based on their feature
181           id, you can also use the fact the 'fid' is a special field
182           recognized by OGR SQL. So, '-where 'fid in (1,3,5)'' would select
183           features 1, 3 and 5.
184
185       -limit nb_features:
186           (starting with GDAL 2.2): to limit the number of features, per
187           layer.
188
189       Srs_def can be a full WKT definition (hard to escape properly), or a
190       well known definition (i.e. EPSG:4326) or a file with a WKT definition.
191
192       Advanced options :
193
194       -oo NAME=VALUE:
195           (starting with GDAL 2.0) Input dataset open option (format
196           specific)
197
198       -doo NAME=VALUE:
199           (starting with GDAL 2.0) Destination dataset open option (format
200           specific), only valid in -update mode
201
202       -gt n:
203           group n features per transaction (default 20000 in OGR 1.11, 200 in
204           previous releases). Increase the value for better performance when
205           writing into DBMS drivers that have transaction support. Starting
206           with GDAL 2.0, n can be set to unlimited to load the data into a
207           single transaction.
208
209       -ds_transaction:
210           (starting with GDAL 2.0) Force the use of a dataset level
211           transaction (for drivers that support such mechanism), especially
212           for drivers such as FileGDB that only support dataset level
213           transaction in emulation mode.
214
215       -clipsrc [xmin ymin xmax ymax]|WKT|datasource|spat_extent:
216           (starting with GDAL 1.7.0) clip geometries to the specified
217           bounding box (expressed in source SRS), WKT geometry (POLYGON or
218           MULTIPOLYGON), from a datasource or to the spatial extent of the
219           -spat option if you use the spat_extent keyword. When specifying a
220           datasource, you will generally want to use it in combination of the
221           -clipsrclayer, -clipsrcwhere or -clipsrcsql options
222
223       -clipsrcsql sql_statement:
224           Select desired geometries using an SQL query instead.
225
226       -clipsrclayer layername:
227           Select the named layer from the source clip datasource.
228
229       -clipsrcwhere expression:
230           Restrict desired geometries based on attribute query.
231
232       -clipdst xmin ymin xmax ymax:
233           (starting with GDAL 1.7.0) clip geometries after reprojection to
234           the specified bounding box (expressed in dest SRS), WKT geometry
235           (POLYGON or MULTIPOLYGON) or from a datasource. When specifying a
236           datasource, you will generally want to use it in combination of the
237           -clipdstlayer, -clipdstwhere or -clipdstsql options
238
239       -clipdstsql sql_statement:
240           Select desired geometries using an SQL query instead.
241
242       -clipdstlayer layername:
243           Select the named layer from the destination clip datasource.
244
245       -clipdstwhere expression:
246           Restrict desired geometries based on attribute query.
247
248       -wrapdateline:
249           (starting with GDAL 1.7.0) split geometries crossing the dateline
250           meridian (long. = +/- 180deg)
251
252       -datelineoffset:
253           (starting with GDAL 1.10) offset from dateline in degrees (default
254           long. = +/- 10deg, geometries within 170deg to -170deg will be
255           split)
256
257       -simplify tolerance:
258           (starting with GDAL 1.9.0) distance tolerance for simplification.
259           Note: the algorithm used preserves topology per feature, in
260           particular for polygon geometries, but not for a whole layer.
261
262       -segmentize max_dist:
263           (starting with GDAL 1.6.0) maximum distance between 2 nodes. Used
264           to create intermediate points
265
266       -fieldTypeToString type1, ...:
267           (starting with GDAL 1.7.0) converts any field of the specified type
268           to a field of type string in the destination layer. Valid types are
269           : Integer, Integer64, Real, String, Date, Time, DateTime, Binary,
270           IntegerList, Integer64List, RealList, StringList. Special value All
271           can be used to convert all fields to strings. This is an alternate
272           way to using the CAST operator of OGR SQL, that may avoid typing a
273           long SQL query. Note that this does not influence the field types
274           used by the source driver, and is only an afterwards conversion.
275
276       -mapFieldType srctype|All=dsttype, ...:
277           (starting with GDAL 2.0) converts any field of the specified type
278           to another type. Valid types are : Integer, Integer64, Real,
279           String, Date, Time, DateTime, Binary, IntegerList, Integer64List,
280           RealList, StringList. Types can also include subtype between
281           parenthesis, such as Integer(Boolean), Real(Float32), ... Special
282           value All can be used to convert all fields to another type. This
283           is an alternate way to using the CAST operator of OGR SQL, that may
284           avoid typing a long SQL query. This is a generalization of
285           -fieldTypeToString. Note that this does not influence the field
286           types used by the source driver, and is only an afterwards
287           conversion.
288
289       -unsetFieldWidth:
290           (starting with GDAL 1.11) set field width and precision to 0.
291
292       -splitlistfields:
293           (starting with GDAL 1.8.0) split fields of type StringList,
294           RealList or IntegerList into as many fields of type String, Real or
295           Integer as necessary.
296
297       -maxsubfields val:
298           To be combined with -splitlistfields to limit the number of
299           subfields created for each split field.
300
301       -explodecollections:
302           (starting with GDAL 1.8.0) produce one feature for each geometry in
303           any kind of geometry collection in the source file
304
305       -zfield field_name:
306           (starting with GDAL 1.8.0) Uses the specified field to fill the Z
307           coordinate of geometries
308
309       -gcp ungeoref_x ungeoref_y georef_x georef_y elevation:
310           (starting with GDAL 1.10.0) Add the indicated ground control point.
311           This option may be provided multiple times to provide a set of
312           GCPs.
313
314       -order n:
315           (starting with GDAL 1.10.0) order of polynomial used for warping (1
316           to 3). The default is to select a polynomial order based on the
317           number of GCPs.
318
319       -tps:
320           (starting with GDAL 1.10.0) Force use of thin plate spline
321           transformer based on available GCPs.
322
323       -fieldmap:
324           (starting with GDAL 1.10.0) Specifies the list of field indexes to
325           be copied from the source to the destination. The (n)th value
326           specified in the list is the index of the field in the target layer
327           definition in which the n(th) field of the source layer must be
328           copied. Index count starts at zero. There must be exactly as many
329           values in the list as the count of the fields in the source layer.
330           We can use the 'identity' setting to specify that the fields should
331           be transferred by using the same order. This setting should be used
332           along with the -append setting.
333
334       -addfields:
335           (starting with GDAL 1.11) This is a specialized version of -append.
336           Contrary to -append, -addfields has the effect of adding, to
337           existing target layers, the new fields found in source layers. This
338           option is useful when merging files that have non-strictly
339           identical structures. This might not work for output formats that
340           don't support adding fields to existing non-empty layers. Note that
341           if you plan to use -addfields, you may need to combine it with
342           -forceNullable, including for the initial import.
343
344       -relaxedFieldNameMatch:
345           (starting with GDAL 1.11) Do field name matching between source and
346           existing target layer in a more relaxed way if the target driver
347           has an implementation for it. [-relaxedFieldNameMatch]
348           [-forceNullable]
349
350       -forceNullable:
351           (starting with GDAL 2.0) Do not propagate not-nullable constraints
352           to target layer if they exist in source layer..
353
354       -unsetDefault:
355           (starting with GDAL 2.0) Do not propagate default field values to
356           target layer if they exist in source layer..
357
358       -unsetFid:
359           (starting with GDAL 2.0) Can be specify to prevent the name of the
360           source FID column and source feature IDs from being re-used for the
361           target layer. This option can for example be useful if selecting
362           source features with a ORDER BY clause.
363
364       -nomd:
365           (starting with GDAL 2.0) To disable copying of metadata from source
366           dataset and layers into target dataset and layers, when supported
367           by output driver.
368
369       -mo 'META-TAG=VALUE':
370           (starting with GDAL 2.0) Passes a metadata key and value to set on
371           the output dataset, when supported by output driver.
372
373       -noNativeData:
374           (starting with GDAL 2.1) To disable copying of native data, i.e.
375           details of source format not captured by OGR abstraction, that are
376           otherwise preserved by some drivers (like GeoJSON) when converting
377           to same format.
378

PERFORMANCE HINTS

380       When writing into transactional DBMS (SQLite/PostgreSQL,MySQL, etc...),
381       it might be beneficial to increase the number of INSERT statements
382       executed between BEGIN TRANSACTION and COMMIT TRANSACTION statements.
383       This number is specified with the -gt option. For example, for SQLite,
384       explicitly defining -gt 65536 ensures optimal performance while
385       populating some table containing many hundredth thousand or million
386       rows. However, note that if there are failed insertions, the scope of
387       -skipfailures is a whole transaction.
388
389       For PostgreSQL, the PG_USE_COPY config option can be set to YES for a
390       significant insertion performance boost. See the PG driver
391       documentation page.
392
393       More generally, consult the documentation page of the input and output
394       drivers for performance hints.
395

C API

397       Starting with GDAL 2.1, this utility is also callable from C with
398       GDALVectorTranslate().
399

EXAMPLE

401       Example appending to an existing layer (both flags need to be used):
402
403       % ogr2ogr -update -append -f PostgreSQL PG:dbname=warmerda abc.tab
404
405       Example reprojecting from ETRS_1989_LAEA_52N_10E to EPSG:4326 and
406       clipping to a bounding box
407
408       % ogr2ogr -wrapdateline -t_srs EPSG:4326 -clipdst -5 40 15 55 france_4326.shp europe_laea.shp
409
410       Example for using the -fieldmap setting. The first field of the source
411       layer is used to fill the third field (index 2 = third field) of the
412       target layer, the second field of the source layer is ignored, the
413       third field of the source layer used to fill the fifth field of the
414       target layer.
415
416       % ogr2ogr -append -fieldmap 2,-1,4 dst.shp src.shp
417
418       More examples are given in the individual format pages.
419

AUTHOR

421       Frank Warmerdam warmerdam@pobox.com, Silke Reimer silke@intevation.de
422
423
424
425GDAL                            Thu Jul 25 2019                     ogr2ogr(1)
Impressum