I am looking for a solution to distribute with a python script equidistant points in QGIS along a polygon. I tried to use the following code example:
Using it in my example (running over each polygon from a polygon shape file):
# Reading a polygon layer pp_layer = QgsVectorLayer("poly.shp" , "polylyr", "ogr") # create layer to store result" pntl = QgsVectorLayer("Point", "name", "memory") pr = pntl.dataProvider() for feature in pp_layer.selectedFeatures(): geom = feature.geometry() currentdistance = self.distance feats =  # geom.asPolyline() while currentdistance < length: point = geom.interpolate(currentdistance) print point fet = QgsFeature() fet.setGeometry(point) feats.append(fet) currentdistance = currentdistance + self.distance pr.addFeatures(feats)
However, when running the code, if fails. I got an error message in the python console
Traceback (most recent call last): File "<input>", line 1, in <module> File "/home2/fun.py", line 92, in run_fun fet.setGeometry(point) TypeError: QgsFeature.setGeometry(QgsGeometry): argument 1 has unexpected type 'NoneType'
an I got an errormessage from qgis
ERROR 1: IllegalArgumentException: LinearIterator only supports lineal geometry components
Does anyone has an idea, if i have an error in my code or is it not possible to solve the question with this approach? I am using QGIS 2.0.1.