[gdal-dev] How to delete shapefile

Frank Warmerdam warmerdam at pobox.com
Tue Jun 16 19:31:25 EDT 2009

Clay, Bruce wrote:
> I am trying to delete a temporary shapefile after running a process with 
> the following code.
> The TestCapability always returns FALSE.  If I call DeleteLayer anyway I 
> get an unsupported operation error messege.
> I am using GDAL 1.5.3 with Visual Studio 2005.
> Is there an error in my code or a different way to delete a shapefile 
> using GDAL or do I have to go to the operating system and find all of 
> the files that make up the shapefile and delete them that way?


It looks like the DeleteLayer support for the shapefile driver was added
for 1.6.0.  So you need to either upgrade or perhaps just delete the files
yourself with unlink().  Make sure the datasource is closed when you do so.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the gdal-dev mailing list