<div dir="ltr">Well, you almost convinced me, but for what I can see from the ogr2ogr docs, if -preserve-fid is not set the output driver is expected to create the FIDs [1]. This means that if a a FID is not set (and not preserved) the GeoJSON output driver should write it.<div>Anyway, don't ant to stress it more. I will open the ticket for a flag on QGIS.</div><div><br></div><div>giovanni<br><div><br></div><div>[1] "Use the FID of the source features instead of letting the output driver to automatically assign a new one"</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-10-10 12:26 GMT+02:00 Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div style="font-family:'monospace';font-size:9pt;font-weight:400;font-style:normal"><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">On mardi 10 octobre 2017 12:20:48 CEST G. Allegri wrote:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> On second thought maybe this flag could be a creation option os the OGR</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> GeoJSON driver. The driver writes the "id" property only if a FID is set.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> Maybe a SET_ID flag (or something more miningful) could force the driver</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> creating the "id" with a sequential integer even if a FID is not set for</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> the features.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> What's your opinion? In case I will open a ticket for OGR.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
</span><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">I don't think this control should be done at the driver level. I'd say that if the GeoJSON CreateFeature() API is called with a feature with a FID set, it should write it.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">The logic to decide whether you create a new sequence, re-use source FID or don't set a FID at all belongs to the upper layers (in that case, QGIS. or ogr2ogr which has -preserve_fid or -unsetFid flags).</p><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Even</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">-- </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Spatialys - Geospatial professional services</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a></p></span></div></blockquote></div><br></div>