<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Have you tried to use the <b style="color: rgb(0, 0, 0);
font-family: Roboto, sans-serif; font-size: 14px; font-style:
normal; font-variant-ligatures: normal; font-variant-caps:
normal; letter-spacing: normal; orphans: 2; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal;
widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;
background-color: rgb(255, 255, 255);">-preserve_fid </b><font
face="Helvetica, Arial, sans-serif"><span style="color: rgb(0,
0, 0); font-size: 14px; font-style: normal;
font-variant-ligatures: normal; font-variant-caps: normal;
letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
background-color: rgb(255, 255, 255);">qualifier</span></font><b
style="color: rgb(0, 0, 0); font-family: Roboto, sans-serif;
font-size: 14px; font-style: normal; font-variant-ligatures:
normal; font-variant-caps: normal; letter-spacing: normal;
orphans: 2; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: 2; word-spacing: 0px;
-webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
255);"> ??<br>
</b></p>
ex. <br>
<pre wrap="">ogr2ogr -preserve_fid -f "SQLite" db2.sqlite db.sqlite test -dsco SPATIALITE=YES
Regards
Bo Victor Thomsen
AestasGIS
</pre>
<div class="moz-cite-prefix">Den 09-12-2016 kl. 00:21 skrev César
Martínez:<br>
</div>
<blockquote
cite="mid:CA+RzLkbxAP+TaHeFmasTW85OSB5iwpCuN8PWLP4VZnka3JivCg@mail.gmail.com"
type="cite">
<pre wrap="">Hi, I am using ogr2ogr to export data from Spatialite to other formats
(such as PostGIS or a new Spatialite db).
The layers have an integer primary key, but this field is ignored in
the output table, as an OGC_FID field is created which uses
consecutive numbers, ignoring the real values of the primary key in
the original field.
This is quite inconvenient, as the layer is quite useless after loosing the PK.
I'll provide one example to make it clearer.
- Input data:
CREATE TABLE test
(id INTEGER NOT NULL PRIMARY KEY,
name TEXT NOT NULL);
SELECT AddGeometryColumn('test', 'the_geom', 4326, 'POINT', 'XY');
INSERT INTO 'test' (id, name, the_geom) VALUES (1, "row1",
GeomFromText('POINT(1.01 2.02)', 4326));
INSERT INTO 'test' (id, name, the_geom) VALUES (3, "row3",
GeomFromText('POINT(3.03 4.04)', 4326));
Now we export the table using ogr2ogr:
ogr2ogr -f "SQLite" db2.sqlite db.sqlite test -dsco SPATIALITE=YES
Now compare both layers:
$ ogrinfo -q db.sqlite test
Layer name: test
OGRFeature(test):1
name (String) = row1
POINT (1.01 2.02)
OGRFeature(test):3
name (String) = row3
POINT (3.03 4.04)
$ ogrinfo -q db2.sqlite test
Layer name: test
OGRFeature(test):1
name (String) = row1
POINT (1.01 2.02)
OGRFeature(test):2
name (String) = row3
POINT (3.03 4.04)
Is this a bug or is an intended behaviour? Is there any way to workaround it?
I am using GDAL version 1.11.3. It also happens when exporting to a
different format such as PostGIS.
Greetings,
César Martinez
</pre>
</blockquote>
<br>
</body>
</html>