In this way, it would be better to save in a temporary shapefile first, and if the process finishes successfully, remove the destination shapefile and copy the temporary shp to the new location.
Le mercredi 21 janvier 2009 à 14:27 +0000, Carson Farmer a écrit : > 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 > -- Lionel Roubeyrie chargé d'études LIMAIR - La Surveillance de l'Air en Limousin http://www.limair.asso.fr _______________________________________________ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user