pyqgis, features geometry type changes to unknown after copying to anoter layer

المشرف العام

Administrator
طاقم الإدارة
Im copying a subset of features from a shapefile based QgsVectorLayer (polyline type shapefile) to a memory based QgsVectorLayer('LineString', layername ,'memory'):

self.lyr_flightlines_selected.startEditing()selected = []for f in self.lyr_flightlines.getFeatures(QgsFeatureRequest().setFilterExpression(u'"id"={}'.format(selected_id))): feat = QgsFeature() feat.setGeometry(f.geometry()) feat.setAttributes(f.attributes()) selected.append(feat) print f.geometry().type(), feat.geometry().type()self.lyr_flightlines_selected.dataProvider().addFeatures(selected)self.lyr_flightlines_selected.commitChanges()Selected layer features are presented on the map without a problem, i can also acccess 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 dont 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)



أكثر...
 
أعلى