I'm copying a subset of features from a shapefile based QgsVectorLayer (polyline type shapefile) to a memory based QgsVectorLayer('LineString', layername ,'memory'):


selected = []
for f in self.lyr_flightlines.getFeatures(QgsFeatureRequest().setFilterExpression(u'"id"={}'.format(selected_id))):
                feat = QgsFeature()

                print f.geometry().type(), feat.geometry().type()


Selected layer features are presented on the map without a problem, I can also access attributes of features I copied into the selection layer. But if I try to access the geometry I get an instance of QgsGeometry, but its type() returns unknown geometry. And if I print for example feat.geometry().asPolyline() I get an empty list. I don't know why, because the features are visible on map?! hence they have to have valid geometry. What am I missing here?

(Using QGIS 2.8.2)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.