Hi All,
I'm trying to figure out how to setup a layer with a unique value
renderer using the python bindings. It seems like it should be
straightforward, but I'm obviously missing something, because it doesn't
work.
This is what I've got so far:
layer = QgCore.QgsVectorLayer('data/title.shp','Title
Parcels','ogr')
layer.setScaleBasedVisibility(True)
layer.setMinScale(minScale)
layer.setMaxScale(maxScale)
blackColor = QtGui.QColor(0,0,0,255)
yellowColor = QtGui.QColor(255,255,190,255)
greenColor = QtGui.QColor(174,241,176,255)
orangeColor = QtGui.QColor(246,197,103,255)
greyColor = QtGui.QColor(178,178,178,255)
rnd = QgCore.QgsUniqueValueRenderer(QgCore.QGis.Polygon)
prov = layer.getDataProvider()
rnd.setClassificationField(prov.indexFromFieldName('Ownership')
sym0 = QgCore.QgsSymbol(QgCore.QGis.Polygon,"0","0","Unknown")
sym0.setFillColor(greyColor)
sym0.setColor(blackColor)
sym1 = QgCore.QgsSymbol(QgCore.QGis.Polygon,"1","1","Private")
sym1.setFillColor(yellowColor)
sym1.setColor(blackColor)
sym2 = QgCore.QgsSymbol(QgCore.QGis.Polygon,"2","2","County")
sym2.setFillColor(orangeColor)
sym2.setColor(blackColor)
sym3 = QgCore.QgsSymbol(QgCore.QGis.Polygon,"3","3","Crown")
sym3.setFillColor(greenColor)
sym3.setColor(blackColor)
rnd.insertValue("0",sym0)
rnd.insertValue("1",sym1)
rnd.insertValue("2",sym2)
rnd.insertValue("3",sym3)
layer.setRenderer(rnd)
The layer itself is a polygon shapefile with a field called "Ownership".
The field is an integer field with four different values, 0 to 3. When
I run my application, the Title Parcels layer is rendered with a black
outline and a white (or perhaps hollow) fill colour.
How do I make the unique value renderer work properly?
Thanks,
Rob McCulley
GIS Coordinator
County of Vermilion River
(780) 846-2244
www.vermilion-river.ab.ca <http://www.vermilion-river.ab.ca/>
_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-user