[Qgis-developer] VectorFileWriter

Tim Sutton tim at linfiniti.com
Mon Nov 26 06:07:57 EST 2007


Hi

> I'd like to destroy the previous existing folder every time the
> VectorFileWriter is launched. How can i do that ?

I recently closed ticket #809 so attempting to write a shp our will
cause it to be overwritten properly now, so manually deleting them
should be needed anymore Thats in SVN head only and will be in the
upcoming 0.9.1 release next month.

Regards

Tim

2007/11/26, Barry Rowlingson <b.rowlingson at lancaster.ac.uk>:
> Nicolas B. wrote:
>
> > The code works but i still have the following error message just before the
> > created shp loads " Note: the following lines were not loaded because Qgis
> > was unable to determine values for the x and y coordinates:"
> > I don't understand why. Any ideas ??
>
>   Does it say which 'following lines' were not loaded? Does your csv
> file have any bad data in it? Is there a header line in the CSV that
> perhaps Qgis doesn't skip? Have you tried the standard Qgis CSV reader
> plugin to see how that reacts?
≈
>
>   Use some python functions for testing file existence?
>
>   >>> os.path.exists("/etc/passwd")
>   True
>   >>> os.path.exists("/etc/qoowoowowo")
>   False
>
> Then use python functions for deleting files - os.unlink() is what you
> want here. Check out the python docs on file handling, and don't forget
> to delete .shp, .shx and .dbf when deleting shapefiles!
>
> > Finally, i'd like to apply symbology properties (graduated colors, field to
> > use, number of classes...) on the loaded shp.
> > Is there a Qgs class to do this ?
>
>   Its all in the API: http://svn.qgis.org/api_doc/html/classes.html
>
>   You have to define a renderer, set its properties - this code should
> define a continuous colour renderer that goes from green to red:
>
>          r=QgsContinuousColorRenderer(layer.vectorType())
>          smin=QgsSymbol(layer.vectorType(), "0","","")
>          smax=QgsSymbol(layer.vectorType(), "100", "","")
>          smin.setPen(QPen(Qt.green, 1.0))
>          smax.setPen(QPen(Qt.red, 1.0))
>          r.setMinimumSymbol(smin)
>          r.setMaximumSymbol(smax)
>          r.setClassificationField(fieldNumber)
>
>    Then set the renderer on the layer:
>
>   layer.setRenderer(r)
>
> [note this code was chopped out of a larger system and so somethings
> might not work...]
>
>   Barry
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.qgis.org
> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
>


-- 
Tim Sutton
QGIS Project Steering Committee Member - Release  Manager
Visit http://qgis.org for a great open source GIS
openModeller Desktop Developer
Visit http://openModeller.sf.net for a great open source ecological
niche modelling tool
Home Page: http://tim.linfiniti.com
Skype: timlinux
Irc: timlinux on #qgis at freenode.net


More information about the Qgis-developer mailing list