I need to draw a line with an arrow head or after drawing the line I need to make it as arrow head line by using Python or can we set any arrow head symbol for line features by using Python?
I seek sample code.
Print composer is one of the very basics. Look for some tutorials on it.
File>new print composer, opens a new window designed for printing. It allows you to format your "drawing" for printing onto any paper size and printing to pdf or image.
the high lighted button show you the one to add the map. click, click one corner and drag to fill up the required area.
Experiment with the buttons along the top and look at the panel to the right side for properties.
# adds a LineLayerStyle (Arrow, dotted)
# layer being a vector layer object of QgsVectorLayer()
def setLineLayerStyle(self, layer, style):
if(style == "arrow"):
sl = QgsSymbolLayerV2Registry.instance().symbolLayerMetadata("LineDecoration").createSymbolLayer({ 'width' : '0.26', 'color' : '0,0,0' })
symbollist = layer.rendererV2().symbols()
symbol = symbollist[0]
symbol.appendSymbolLayer(sl)
Following this code, you will get a line that looks like the pink arrow. All of this information is from here
When I tried the to use code based on the answer by @GreyEyedPallas (in QGIS 2.18), I got a message:
AttributeError: 'NoneType' object has no attribute 'createSymbolLayer'
To fix this, I needed to use ArrowLine
instead of LineDecoration
as follows:
sl = QgsSymbolLayerV2Registry.instance().symbolLayerMetadata("ArrowLine").createSymbolLayer({ 'width' : '0.26', 'color' : '0,0,0' })
symbollist = layer.rendererV2().symbols()
symbol = symbollist[0]
symbol.appendSymbolLayer(sl)
Create a new vector layer. Make it a point.
Place your points in the viewer, ensuring that each point can be attributed at least one value...eg. 1, 2, 3, 4..etc.
Open the properties box of the layer. In Style, change single symbol to categorised, change the symbol to show point as an arrow.
Classify and you will have a list of different arrows for each point.
Click on each, you can adjust their size and rotation seperately.
See image: