<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@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;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
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;}
pre
{mso-style-priority:99;
mso-style-link:"HTML-esimuotoiltu Char";
margin:0cm;
font-size:10.0pt;
font-family:"Courier New";
mso-fareast-language:FI;}
span.HTML-esimuotoiltuChar
{mso-style-name:"HTML-esimuotoiltu Char";
mso-style-priority:99;
mso-style-link:HTML-esimuotoiltu;
font-family:Consolas;
mso-fareast-language:EN-US;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 2.0cm 70.85pt 2.0cm;}
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]-->
</head>
<body lang="FI" link="#0563C1" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US">I believe this resolves my previous problem by the same. The indirect_sqlite dialect is not so handy in this case because it wants do download the whole collection from OAPIF.<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">So because OAPIF is sending data as GeoJSON there is no name for the FID column and it is obligatory to use ogr2ogr with “-preserve_fid” if the aim is to preserve FID. I will see if there is something to improve with
this in the documentation. I had some trouble with joining edited data with the original because 15 million feature ids changed into counting numbers.<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-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="mso-fareast-language:FI">Lähettäjä:</span></b><span style="mso-fareast-language:FI"> Even Rouault <even.rouault@spatialys.com>
<br>
<b>Lähetetty:</b> maanantai 21. kesäkuuta 2021 18.09<br>
<b>Vastaanottaja:</b> Rahkonen Jukka (MML) <jukka.rahkonen@maanmittauslaitos.fi>; 'gdal-dev@lists.osgeo.org' <gdal-dev@lists.osgeo.org><br>
<b>Aihe:</b> Re: [gdal-dev] Converting fid from GeoJSON into GeoPackage<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Jukka,<span style="mso-fareast-language:FI"><o:p></o:p></span></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.<o:p></o:p></p>
<p>Even<o:p></o:p></p>
<div>
<p class="MsoNormal">Le 21/06/2021 à 17:04, Rahkonen Jukka (MML) a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US">Hi,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Take this GeoJSON<br>
<br>
{</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">"type": "FeatureCollection",</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">"features": [{</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">"type": "Feature",</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">"id":12425552,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">"properties": </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">{</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">},</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">"geometry": {</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">"type": "Point",</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">"coordinates": [26.30578223, 60.26170791]</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">}</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">}]</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">}</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Ogrinfo knows the fid</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">OGRFeature(one_feature):12425552</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Convert into a new GeoPackage and the native fid is lost</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">ogr2ogr -f gpkg one_feature.gpkg one_feature.json</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">OGRFeature(one_feature):1</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></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">https://gdal.org/programs/ogr2ogr.html</a> that should not be needed:</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></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.”</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Is the error in the documentation or in the GeoJSON-GeoPackage conversion?</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">-Jukka Rahkonen-<br>
<br>
<br>
</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:FI"><br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>gdal-dev mailing list<o:p></o:p></pre>
<pre><a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><o:p></o:p></pre>
<pre><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre><a href="http://www.spatialys.com">http://www.spatialys.com</a><o:p></o:p></pre>
<pre>My software is free, but my time generally not.<o:p></o:p></pre>
</div>
</body>
</html>