<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<p>Jukka,</p>
<p>Automatic FID preservation requires that the source layer reports
a non-empty column name for the FID column, which isn't the case
of the GeoJSON driver. Mostly only SQL-based drivers will report a
non-empty FID column name.</p>
<p>Even<br>
</p>
<div class="moz-cite-prefix">Le 21/06/2021 à 17:04, Rahkonen Jukka
(MML) a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:09104585cae44fa888362b92a278ec0e@maanmittauslaitos.fi">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}span.Shkpostityyli18
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Take this GeoJSON<br>
<br>
{<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">"type":
"FeatureCollection",<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">"features": [{<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">"type": "Feature",<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">"id":12425552,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">"properties": <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">{<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">},<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">"geometry": {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">"type": "Point",<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">"coordinates":
[26.30578223, 60.26170791]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">}<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">}]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">}<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Ogrinfo knows the fid<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">OGRFeature(one_feature):12425552<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Convert into a new
GeoPackage and the native fid is lost<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">ogr2ogr -f gpkg
one_feature.gpkg one_feature.json<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">OGRFeature(one_feature):1<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Running the command with
“-preserve_fid” keeps the native fid but according to
ogr2ogr documentation
<a href="https://gdal.org/programs/ogr2ogr.html"
moz-do-not-send="true">https://gdal.org/programs/ogr2ogr.html</a>
that should not be needed:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">“Use the FID of the
source features instead of letting the output driver
automatically assign a new one (for formats that require a
FID). If not in append mode, this behavior is the default if
the output driver has a FID layer creation option, in which
case the name of the source FID column will be used and
source feature IDs will be attempted to be preserved.”<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Is the error in the
documentation or in the GeoJSON-GeoPackage conversion?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">-Jukka Rahkonen-<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>