I'm trying to create a polygon layer from 4 points that I have already defined. There issue here is that I'm always getting the following error:
AttributeError: type object 'QgsGeometry' has no attribute 'fromPolygon'
These are the points (printed in console):
print (points)
<QgsPoint: Point (546016.50083752069622278 4760165.85990538075566292)>
<QgsPoint: Point (535433.25716883409768343 4749582.61623669415712357)>
<QgsPoint: Point (559882.5150161839555949 4746299.84572671726346016)>
<QgsPoint: Point (549299.27134749735705554 4735716.60205803066492081)>
And here is the code that produces the error above:
layer = QgsVectorLayer(str('Polygon?crs='+crs), 'polygon' , 'memory')
prov = layer.dataProvider()
points = [H1V1p,H1V2p,H2V1p,H2V2p]
feat = QgsFeature()
feat.setGeometry(QgsGeometry.fromPolygon([points]))
prov.addFeatures([feat])
layer.updateExtents()
QgsMapLayerRegistry.instance().addMapLayers([layer])