2

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))
        point.setIconSize(20)
        poly_points.append(QgsPoint(feature[0], feature[1]))
    poly.setToGeometry(QgsGeometry.fromPolygon([poly_points]), None)
    poly.setColor(QColor(0, 150, 150))
    poly.setWidth(3)

I am using QGIS 2.18.

1
  • The function works correctly. You may be using unexpected Polypoints. Commented Dec 10, 2019 at 21:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.