<div dir="ltr">Dear Ujaval<div>Thank you for your reply.</div><div>This is my code snippet:</div><div>def createPointsAt(distance, geom):# creates point at certain distance saving the joint points of the original geometry <br>    if distance > geom.length():<br>        distance=geom.length()<br>    polyline=[]<br>    polyline=polyline+geom.asPolyline()<br>    points=[]<br>    interpolated_polyline=[]<br>    for f in range (0,len(polyline)-1):<br>        interpolated_polyline=geom.fromPolylineXY([polyline[f],polyline[f+1]])#line section of a polyline<br>        # set the first point at startpoint<br>        startpoint=0<br>        point = interpolated_polyline.interpolate(startpoint)<br>        current_distance = distance<br>        length = interpolated_polyline.length()<br>        # convert 3D geometry to 2D geometry as OGR seems to have problems with this<br>        points.append((point.asPoint()[0],point.asPoint()[1]))<br>        while startpoint + current_distance <= length:<br>            # Get a point along the line at the current distance<br>            point = interpolated_polyline.interpolate(startpoint + current_distance)<br>            points.append((point.asPoint()[0],point.asPoint()[1]))<br>            # Increase the distance<br>            current_distance = current_distance + distance<br>        # set the last point at endpoint if wanted<br>        end = interpolated_polyline.length()<br>        point = interpolated_polyline.interpolate(end)<br>        points.append((point.asPoint()[0],point.asPoint()[1]))<br>    return points<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 8, 2022 at 3:13 PM Ujaval Gandhi <<a href="mailto:ujaval@spatialthoughts.com">ujaval@spatialthoughts.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"> There's a tool 'Points along geometry' in the Processing Toolbox that can do this. Can you use that?<div><br></div><div>If you are trying to do this with PyQGIS, share your code snippet so folks can suggest how to do it.<br clear="all"><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div></div><div><table cellpadding="0" cellspacing="0" style="border-spacing:0px;border-collapse:collapse;color:rgb(68,68,68);width:480px;font-size:10pt;font-family:Arial,sans-serif;line-height:normal"><tbody><tr><td valign="top" style="padding:10px 0px 12px;width:160px;vertical-align:top"><a href="https://spatialthoughts.com/" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img border="0" alt="Logo" width="141" src="https://spatialthoughts685850346.files.wordpress.com/2019/12/spatial_thoughts_logo.png" style="border: 0px; vertical-align: middle; width: 141px; height: auto;"></a></td><td style="padding:6px 0px;width:320px"><table cellpadding="0" cellspacing="0" style="border-spacing:0px;border-collapse:collapse;background-color:transparent"><tbody><tr><td style="padding:0px;font-size:12pt;font-family:Arial,sans-serif;font-weight:bold;color:rgb(61,60,63)"><span style="color:rgb(0,175,239)">Ujaval Gandhi</span></td></tr><tr><td style="padding:0px 0px 11px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(61,60,63)"><span style="color:rgb(0,175,239)">Spatial Thoughts</span></td></tr><tr><td style="padding:0px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(155,155,155)"><span>mobile: +91-8095684687</span></td></tr><tr><td style="padding:0px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(155,155,155)"><span>email: </span><span style="color:rgb(23,147,210)"><a href="mailto:ujaval@spatialthoughts.com" target="_blank">ujaval@spatialthoughts.com</a></span></td></tr><tr><td style="padding:6px 0px 0px"><span style="display:inline-block;height:22px"><span><a href="https://www.linkedin.com/in/spatialthoughts/" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img alt="LinkedIn icon" border="0" width="23" height="23" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/elegant-logo/ln.png" style="border: 0px; vertical-align: middle; height: 20px; width: 20px;"></a>  </span><span><a href="https://twitter.com/spatialthoughts" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img alt="Twitter icon" border="0" width="23" height="23" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/elegant-logo/tt.png" style="border: 0px; vertical-align: middle; height: 20px; width: 20px;"></a>  </span></span></td></tr></tbody></table></td></tr><tr><td colspan="2" style="padding:8px 0px 0px;border-top:1px solid rgb(23,147,210);width:480px;font-family:Arial,sans-serif;color:rgb(155,155,155);text-align:justify"></td></tr></tbody></table><br></div></div></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 8, 2022 at 7:22 PM Asim al-sofi <<a href="mailto:asim56@gmail.com" target="_blank">asim56@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear all,<div>I am asking for help with interpolating a geometry.<br><div>I have a geometry say "<b>geom</b>" and want to add new points to it at fixed distances, say "<b>distance</b>".<br></div><div>Using the method "interpolate" i.e., <b>geom</b>.interpolate(<b>distance</b>) returns only points at the interpolated distance(s), meaning the geometry points between the interpolated points are unknown.<br>Is there a method to insert the interpolated points into the <b>geom</b>(of course at the right positions)? <br>With other words, how to create a new geometry that contains the points of the old geometry and the interpolated points?<br><br>Kind regards,<br>Asim<br></div></div></div>
_______________________________________________<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/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</blockquote></div>
</blockquote></div>