winnerfert.blogg.se

Draw perpendicular line gsp5
Draw perpendicular line gsp5








draw perpendicular line gsp5

I employed above code with next layers where you can have two possible situations.Īfter running the code, at the Python Console of QGIS were printed two Line Strings in WKT format. I need only second term, geom, that is a QgsPointĬlosest_line = omPolyline(.geometry().asPoint(),

draw perpendicular line gsp5

Geoms = [ feat_line.geometry().closestSegmentWithContext(feat.geometry().asPoint()) getFeatures() ]įeat_line = layers.getFeatures().next() mapcanvas = iface.mapCanvas()įeat_points =. I used 'closestSegmentWithContext' of QgsGeometry instead. For this reason you can avoid to use your 'intersect_point_to_line' function. PyQGIS also has classes to find 'Closest Segments'. I do that with QgsMapCanvas class in the next code. Iy = line_start.y() + u * (line_end.y() - line_start.y()) Ix = line_start.x() + u * (line_end.x() - line_start.x()) Magnitude2 = line_start.sqrDist(line_end) # sqrDist of the line (PyQGIS function = magnitude (length) of a line **2) ''' Calc minimum distance from a point and a line segment and intersection''' Line = omPolyline()ĭef intersect_point_to_line(point, line_start, line_end): I found this code, but how can I call the points in the Point Layer and the lines in the Line layer generally? How can I can iterate over them with a loop to find/create the perpendicular line in between? # basic example with PyQGIS The QGIS geoalgorithm "DISTANCE TO NEAREST HUB" isn't helpful because the nearest hub isn't perpendicular. I have to iterate over a point and line layer to draw the perpendicular line from each point to the nearest line.










Draw perpendicular line gsp5