-1

I need to draw line with arrow head or after drawn 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? Kindly help me with some sample codes.

  • why do you need to do it with python. why not in print composer? – Ger Apr 30 '13 at 13:01
  • print composer means? i'm very new to this..could you plz explain – venkat Apr 30 '13 at 13:04
  • Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Oct 28 '16 at 11:51
1

Ok well 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.

enter image description here

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.

  • Thanks but this one i cannt save as QgsVectorLayer. i need to make line feature with arrow head in QgsVectorLayer. plz help me – venkat May 2 '13 at 4:26
1

I'm three years late, but hopefully whoever else might be stuck on an issue like this will benefit from my answer.

 # 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.

Following this code, you will get a line that looks like the pink arrow. All of this information is from here

  • Also, there is an Arrows plugin (bitbucket.org/gpiffault/qgis-plugins/wiki/Arrows) by Gregoire Piffault that creates a stylized arrow. It has some issues but it works, just delete the existing arrows shape file between iterations. – marcp Jul 21 '16 at 16:55
  • This code doesn't seem to work in QGIS 2.18, though changing LineDecoration to ArrowLine as per my answer here does. – Jonny Jan 22 '18 at 15:53
0

OK Having reviewed what you said. 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 imageenter image description here

  • thanks for your response.. actually i need this for line feature. – venkat May 2 '13 at 12:03
0

Almost 5 years since the original post now, but 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)

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.