now I want to use QgsPolygon (and Qgspolyline,too) class in python
I have a example by using QgsPoint but I don't know how to use in QgsPolygon
following is my Qgspoint example
feature = QgsFeature()
qpoint = QgsPoint( float(x), float(y) ) #get qpoint's attitube here
feature.setGeometry(QgsGeometry.fromPoint(qpoint))#set point's geometry here
if numpy.isnan(val):
pass #no assign value means assign NULL value
else:
attr_val = round(val,4)
feature.addAttribute(0,QVariant(attr_val))
feature_list.append(feature)#append value here
I want to change QgsPolygon(or QgsPolyline) instead of QgsPoint but I couldn't find the variables of QgsPolygon(or QgsPolyline)
where to find the variables of QgsPolygon and QgsPolyline?
I have another problem here ,
for s in dataset:
x=s[0]
y=s[1]
feature = QgsFeature()
qpoint = QgsPoint( float(x) , float(y) )
polygon=[]
polygon.append(qpoint)
feature.setGeometry(QgsGeometry.fromPolygon([polygon]))
but it's still get
TypeError: QgsFeature.setGeometry(): argument 1 has unexpeced type 'NoneType'
how to fix it?
Have I mistake the meaning of your answer?