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

Even Rouault even.rouault at spatialys.com
Tue Nov 28 16:01:42 PST 2017


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_frmts/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/ea8e9ff0/attachment.html>


More information about the gdal-dev mailing list