I have a script which has an unrelated error after the draw_polygon function. I don't care about the error at the moment because I want to see the current results. For some reason my draw function doesn't work. My thought was that the drawing of QgsRubberBand happens after the succesful completion of a function?

def draw_polygon(Polypoints):
    point = QgsVertexMarker(canvas)
    poly = QgsRubberBand(canvas, True)
    poly_points = []
    for feature in Polypoints:
        point.setCenter(QgsPoint(feature[0], feature[1]))
        point.setColor(QColor(255, 150, 0))
        poly_points.append(QgsPoint(feature[0], feature[1]))
    poly.setToGeometry(QgsGeometry.fromPolygon([poly_points]), None)
    poly.setColor(QColor(0, 150, 150))

I am using QGIS 2.18.

  • The function works correctly. You may be using unexpected Polypoints. – Kadir Şahbaz Dec 10 '19 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.