<div dir="ltr"><div>Thanks, this helps! </div><div><br></div><div>The thing is I cannot really use layer name to identify an AmigoCloud dataset. In AmigoCloud we have names, but they are not guarantied to be unique. We use dataset Id to identify a dataset (ogr layer) instead. In my example "Visits" it's just a name of the source data file, which gdal uses as a layer name. This is fine, but for destination AmigoCloud dataset I specify a dataset id explicitly anyway. So I know my destination dataset, and if it exists or not. I think with the info I have now I could do few small changes to handle these cases.</div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><b>Victor Chernetsky</b></div><div><b><br></b></div><div><div><b><img src="http://www.amigocloud.com/static/homepage/img/e-mail-signature.png" width="96" height="22"><br></b><div><font color="#000000">+1 </font><font color="#000000">(408) 368-4607</font></div><div><a href="mailto:victor@amigocloud.com" style="color:rgb(17,85,204)" target="_blank">victor@amigocloud.com</a><br></div></div></div></div></div></div>
<br><div class="gmail_quote">On Tue, Nov 28, 2017 at 4:01 PM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<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:'Sans Serif';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 28 novembre 2017 15:40:46 CET Victor Chernetsky wrote:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> Here is my example:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> ogr2ogr -overwrite -f AmigoCloud "AmigoCloud:15276 datasets=100056"</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> ~/Downloads/Visits.geojson</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">> I am trying to append, or overwrite data into existing dataset id:100056.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> But it still created a new dataset, and it did not delete/clean old</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> dataset.</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">-overwrite overwrite *layers* not datasets</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Here it will probably create a new layer because the layer name of Visits.geojson</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">must be "Visits" and probably doesn't exist yet in your dataset.</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">If you want to overwrite an existing layer foo with the geojson, you must add "-nln foo"</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">> I am thinking I need to do something in</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> my OGRAmigoCloudDataSource::<wbr>ICreateLayer(). I am not checking if dataset</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> exist. I always create a new one.</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">You can have a look at the ogr2ogr logic to decide how to overwrite a layer:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><a href="https://github.com/OSGeo/gdal/blob/trunk/gdal/apps/ogr2ogr_lib.cpp#L3180" target="_blank">https://github.com/OSGeo/gdal/<wbr>blob/trunk/gdal/apps/ogr2ogr_<wbr>lib.cpp#L3180</a></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">For non-ogr2ogr clients, you could indeed add a check if a layer of same name already exists</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">A number of drivers also support a OVERWRITE=YES layer creation option</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">See </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><a href="https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrsf_frmts/carto/ogrcartodatasource.cpp#L412" target="_blank">https://github.com/OSGeo/gdal/<wbr>blob/trunk/gdal/ogr/ogrsf_<wbr>frmts/carto/<wbr>ogrcartodatasource.cpp#L412</a></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">The advantage when you write an example is that you have tens of examples to get inspiration from ;-)</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>