[Qgis-developer] Coloring shapes of vector layer
Marco Bernasocchi
marco at bernawebdesign.ch
Mon Apr 11 07:46:47 EDT 2011
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
More information about the Qgis-developer
mailing list