3

I want to addd a Layer and give the layer a color for the border and for the filling. With the code below i am possible to achieve a color for the border, but a did not found a solution to give a color for the filling. In addition, is it possible to change the width of the border line?

uri.setDataSource("shema_name", "layer_name", "geom","","layer_name_id")
lyr = QgsVectorLayer(uri.uri(), "layer_name_you_like", "postgres")

props = { 'color_border' : '255,165,0,125', 'style' : 'no', 'style_border' : 'solid' }
s = QgsFillSymbolV2.createSimple(props)
lyr.setRendererV2( QgsSingleSymbolRendererV2( s ) )

QgsMapLayerRegistry.instance().addMapLayer(lyr)

1 Answer 1

3

I partially solved my question. Looking at a .qgs file properties to rendererV2 look e.g.:

 <renderer-v2 symbollevels="0" type="singleSymbol">
            <symbols>
                <symbol outputUnit="MM" alpha="0.3803921568627451" type="fill" name="0">
                    <layer pass="0" class="SimpleFill" locked="0">
                        <prop k="color" v="255,165,0,97"/>
                        <prop k="color_border" v="255,165,0,97"/>
                        <prop k="offset" v="0,0"/>
                        <prop k="style" v="solid"/>
                        <prop k="style_border" v="solid"/>
                        <prop k="width_border" v="1"/>
                    </layer>
                </symbol>
            </symbols>
            <rotation field=""/>
            <sizescale field=""/>
        </renderer-v2>

Thus, setting properties assigned with the prop-tag is clear now. However, what ist the phytonic way to set the properties in layer- tag and the the symbol-tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.