<div dir="ltr">Hi Alessandro,<div>you may use an edited version of the code that I posted for answering to a GIS StackExchange question (linked <a href="http://gis.stackexchange.com/questions/228419/connecting-points-to-polygon-edges-using-angular-bearing">here</a>).</div><div><br></div><div>I slightly edited it for you, but refers to the answer from GIS SE for a better understanding (remember to adapt the field names in the code to your specifi case):</div><div><br></div><div>####### CODE STARTS HERE ###########</div><div><br></div><div><div>##Points=vector point</div><div><br></div><div>from qgis.core import *</div><div>from qgis.PyQt.QtCore import QVariant</div><div>import math</div><div><br></div><div>p_layer = processing.getObject(Points)</div><div>crs = p_layer.crs().toWkt()</div><div><br></div><div># Create the output layer</div><div>outLayer = QgsVectorLayer('Linestring?crs='+ crs, 'land' , 'memory')</div><div>prov = outLayer.dataProvider()</div><div>fields = p_layer.pendingFields()</div><div>prov.addAttributes(fields)</div><div>outLayer.updateFields()</div><div><br></div><div>for feat in p_layer.getFeatures():</div><div>    attrs = feat.attributes()</div><div>    point = feat.geometry().asPoint()</div><div>    points = [feat.geometry().asPoint()]</div><div>    angle = math.radians(90-(feat["azimuth"]))</div><div>    tmp_len = (feat["length"])</div><div>    dist_x, dist_y = (tmp_len * math.cos(angle), tmp_len * math.sin(angle))</div><div>    point2 = QgsPoint(point[0] + dist_x, point[1] + dist_y)</div><div>    points.append(point2)</div><div>    outFeat = QgsFeature()</div><div>    outFeat.setAttributes(attrs)</div><div>    outFeat.setGeometry(QgsGeometry.fromPolyline(points))</div><div>    prov.addFeatures([outFeat])</div><div>    </div><div># Add the layer to the Layers panel</div><div>QgsMapLayerRegistry.instance().addMapLayer(outLayer)</div></div><div><br></div><div>####### CODE ENDS HERE ###########<br></div><div><br></div><div>Marco Grisolia</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-15 10:41 GMT+01:00  <span dir="ltr"><<a href="mailto:alessandro.conforti@cnr.it" target="_blank">alessandro.conforti@cnr.it</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi to all Qgis user,<br>
I've a question for you guys:<br>
I've a point shape file, in the features table 'i've a field with the azimut value in degree and another field with a lenth in meters.<br>
i would like to produce a new line shape file with a vector tha has origin on the point azimut from the azimut field table and length from lenght value in metres.<br>
Sonbody can help me?<br>
thanks in advance<br>
Ale<br>
<br>
______________________________<wbr>_________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a></blockquote></div><br></div>