[Qgis-developer] Coloring shapes of vector layer

Goo Creations goocreations at gmail.com
Mon Apr 11 08:16:15 EDT 2011


Hey, thank you. It worked.
However, some Qgis code changed (eg: createSimple doesn't exist anymore), so
I had to adapt a little bit.

On Mon, Apr 11, 2011 at 1:46 PM, Marco Bernasocchi
<marco at bernawebdesign.ch>wrote:

> Hi Chris,
> have you looked at [1]?
> here my sample code using rendererV2:
>
> layer = QgsVectorLayer("Point?crs=epsg:4326", "myLayer", "memory")
> symbol = QgsMarkerSymbolV2.createSimple( { 'color' : '0,255,128' } )
> layer.setRendererV2( QgsSingleSymbolRendererV2( symbol ) )
>
> ciao Marco
> [1]
>
> http://www.qgis.org/pyqgis-cookbook/vector.html#appearance-symbology-of-vector-layers
>
> On 04/11/2011 12:58 PM, Goo Creations wrote:
> > Hi
> >
> > I've got a vector file (shp) with a bunch of points in it. I want to
> > load the points to the canvas with a specific color (not the random
> > color QGIS provides). I've tried a couple of tutorials, but the code
> > provided doesn't change the color.
> >
> > /mask = QgsVectorLayer(maskPath, "my_mask", "ogr")/
> > /sy = QgsSymbol( mask.geometryType() )/
> > /sy.setFillColor(Qt.red)/
> > /    /
> > /renderer = QgsSingleSymbolRenderer( mask.geometryType() )/
> > /renderer.addSymbol( sy )/
> > /renderer.updateSymbolAttributes()/
> > /    /
> > /mask.setRenderer( renderer )/
> > /mask.triggerRepaint()/
> > /self.iface.legendInterface().refreshLayerSymbology(mask)/
> >
> > Did I forget anything, or should I do something diffrently?
> >
> > Chris
> >
> >
> >
> > _______________________________________________
> > Qgis-developer mailing list
> > Qgis-developer at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> --
> Marco Bernasocchi
> www.bernawebdesign.ch
> skype: mbernasocchi
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20110411/fa733c20/attachment.html


More information about the Qgis-developer mailing list