Create a New Feature
fn = 'C:/pyqgis/vector/id_roads_copy.shp' lyr = QgsVectorLayer(fn, 'roads', 'ogr') newfeat = QgsFeature(lyr.fields()) newfeat.setAttributes(['1005', 'added new feature', 'zz', 'zzz']) geom = QgsGeometry.fromPolyline([QgsPoint(-117.0, 40.0), QgsPoint(-110.0, 40.0)]) newfeat.setGeometry(geom) lyr.dataProvider().addFeatures([newfeat])