I am trying to create some code to generate 10 random points within a vector layer's districts:
layer=iface.activeLayer()
import ogr
import sys
import random
from shapely import wkb, geometry
Moz_no=layer.featureCount()
for i in xrange(Moz_no):
district_tmp=layer.getFeatures(i)
district=wkb.loads(district_tmp.GetGeometryRef().ExportToWkb())
random_point_count=0
sys.stdout.write("\r")
sys.stdout.flush()
while random_point_count<11:
maxx, maxy, minx, miny = district.bounds
random_point=geometry.Point(minx_+(random.random()*(maxx-minx)), (miny+ (random.random()*(maxy-miny))))
However, when I run the code, it gives me this error:
TypeError: QgsVectorLayer.getFeatures(QgsFeatureRequest request=QgsFeatureRequest()): argument 1 has unexpected type 'int'
Could someone please help me, and explain what is going on?