5

From Python console I load a shapefile with qgis.utils.iface.addVectorLayer. How I can remove border lines (change to no pen) in the active layer?

2

This assumes you are using the new symbology renderer (which is the default):

from PyQt4.QtCore import *    
lyr = QgsVectorLayer('/data/world_borders.shp', 'world_borders', 'ogr')
QgsMapLayerRegistry.instance().addMapLayer(lyr)
renderer = lyr.rendererV2()
symbol = QgsFillSymbolV2.createSimple({QString('style'): QString('solid'), QString('color'): QString('255,0,0,255'), QString('style_border'):QString('no')})
renderer.setSymbol(symbol)

Then trigger a repaint for the layer and update the legend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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