[gdal-dev] Question about command line options -append

Victor Chernetsky victor at amigocloud.com
Wed Nov 29 12:00:17 PST 2017


Hey Even,

How do I set OVERWRITE option?
I tried all these:
ogr2ogr -overwrite -f AmigoCloud "AmigoCloud:15276 datasets=100322"
~/Downloads/Visits.geojson
ogr2ogr --config OVERWRITE YES -f AmigoCloud "AmigoCloud:15276
datasets=100322" ~/Downloads/Visits.geojson
ogr2ogr -oo OVERWRITE=YES -f AmigoCloud "AmigoCloud:15276 datasets=100322"
~/Downloads/Visits.geojson

In my driver CSLFetchNameValue( papszOptions, "OVERWRITE" ) is always NULL,
and DeleteLayer(int iLayer) never gets called.

How do switch ogr2ogr onto overwrite mode? Or how do I catch it in my
driver?

Thanks,


*Victor Chernetsky*


+1 (408) 368-4607
victor at amigocloud.com

On Tue, Nov 28, 2017 at 4:26 PM, Victor Chernetsky <victor at amigocloud.com>
wrote:

> Thanks, this helps!
>
> 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.
>
>
>
> *Victor Chernetsky*
>
>
> +1 (408) 368-4607
> victor at amigocloud.com
>
> On Tue, Nov 28, 2017 at 4:01 PM, Even Rouault <even.rouault at spatialys.com>
> wrote:
>
>> On mardi 28 novembre 2017 15:40:46 CET Victor Chernetsky wrote:
>>
>> > Here is my example:
>>
>> > ogr2ogr -overwrite -f AmigoCloud "AmigoCloud:15276 datasets=100056"
>>
>> > ~/Downloads/Visits.geojson
>>
>> >
>>
>> > I am trying to append, or overwrite data into existing dataset
>> id:100056.
>>
>> > But it still created a new dataset, and it did not delete/clean old
>>
>> > dataset.
>>
>>
>>
>> -overwrite overwrite *layers* not datasets
>>
>> Here it will probably create a new layer because the layer name of
>> Visits.geojson
>>
>> must be "Visits" and probably doesn't exist yet in your dataset.
>>
>>
>>
>> If you want to overwrite an existing layer foo with the geojson, you must
>> add "-nln foo"
>>
>>
>>
>> > I am thinking I need to do something in
>>
>> > my OGRAmigoCloudDataSource::ICreateLayer(). I am not checking if
>> dataset
>>
>> > exist. I always create a new one.
>>
>>
>>
>> You can have a look at the ogr2ogr logic to decide how to overwrite a
>> layer:
>>
>> https://github.com/OSGeo/gdal/blob/trunk/gdal/apps/ogr2ogr_lib.cpp#L3180
>>
>>
>>
>> For non-ogr2ogr clients, you could indeed add a check if a layer of same
>> name already exists
>>
>> A number of drivers also support a OVERWRITE=YES layer creation option
>>
>> See
>>
>> https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrsf_frmt
>> s/carto/ogrcartodatasource.cpp#L412
>>
>>
>>
>> The advantage when you write an example is that you have tens of examples
>> to get inspiration from ;-)
>>
>>
>>
>> Even
>>
>>
>>
>> --
>>
>> Spatialys - Geospatial professional services
>>
>> http://www.spatialys.com
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171129/a31e2680/attachment.html>


More information about the gdal-dev mailing list