[gdal-dev] Using -overwrite to create empty feature class

Even Rouault even.rouault at mines-paris.org
Fri Feb 3 17:19:47 EST 2012


Le vendredi 03 février 2012 22:59:36, Donovan Cameron a écrit :
> FYI
> 
> Further testing with -overwrite given your explanation
> *ogr2ogr -overwrite output.shp output.shp -progress*
> ...works as well but only if the files are in the same output directory

Overwriting the source file with itself is definitely not supported. Do at your 
own risk ! The DBF error isn't surprising in that context.

> 
> But it does report a dbf error:
> *ERROR 1: fread(631) failed on DBF file.*
> 
> But I can still open the output for appending and view the results in a GIS
> viewer like QGIS.
> 
> Though the -where or -fid trick works as well
> 
> On Wed, Feb 1, 2012 at 2:38 PM, Even Rouault
> 
> <even.rouault at mines-paris.org>wrote:
> > Le mercredi 01 février 2012 22:22:42, Donovan Cameron a écrit :
> > > Afternoon List.
> > > 
> > > I am trying to generate an empty feature (shp or gml) from a template
> > 
> > that
> > 
> > > retains both the attribute-table schema and map projection.
> > > 
> > > I can't get the *-overwrite *flag to work, it just copies the entire
> > > feature (ie, makes a duplicate):
> > > *ogr2ogr -overwrite -f "GML" geoname.gml /vsizip/vsicurl/
> > > ${inZIP}/${inGML}* *
> > > *
> > > The next commands <http://gis.stackexchange.com/a/16510/1297>[1] work
> > 
> > using
> > 
> > > *-where *or *-fid*:
> > > *ogr2ogr -f "GML" geoname.gml /vsizip/vsicurl/ ${inZIP}/${inGML} -where
> > > "FID < 0"*
> > > *ogr2ogr -f "GML" geoname.gml /vsizip/vsicurl/ ${inZIP}/${inGML} -fid
> > > "< 0"*
> > > 
> > > I thought the* -overwrite* flag would delete the output layer and
> > 
> > recreate
> > 
> > > it empty <http://www.gdal.org/ogr2ogr.html>[2]?
> > 
> > -overwrite deletes the output layer, so that the new features added by
> > ogr2ogr
> > aren't added to the previously existing one, but in no way it creates an
> > empty
> > layer.
> > 
> > The -where "fid < 0" trick is actually an interesting one. I've no better
> > suggestion.


More information about the gdal-dev mailing list