Cedric,
Hi list

in a python plugin im using QgsVectorFileWriter.writeAsShapefile to write a 
shapefile to the disk.

The first time I use a certain file name/path (e.g /tmp/foo.shp), it works properly. If I try to rerun the script, it fails saying: ERROR 1: /tmp/foo.shp is not a directory.

It looks like it is not possible to replace an existing shapefile that way. Am 
I correct? Do I have to manage the files myself (i.e. delete them before 
writing the new file)? Or is there another way to replace an existing shapefile?

Yes you are correct, you cannot overwrite shapfiles like that... but you can do the following first:

QgsVectorFileWriter.deleteShapefile( "path/to/the/shapefile/shp" )


Cheers,

Carson

--
Carson J. Q. Farmer
ISSP Doctoral Fellow
National Centre for Geocomputation (NCG),
Email: [email protected]
Web:   http://www.carsonfarmer.com/
      http://www.ftools.ca/


_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to