I'm using QGIS 2.2.0. I add a vector to a vector layer and save the file. After I reopen the .qgs file, the new vector is not shown.

(1) Click 'Toggle Editing'

enter image description here

(2) Click 'Add Feature' and draw a polyline.

enter image description here

(3) Click 'Save Layer Edits'

enter image description here

(4) Click 'Save'

enter image description here

  • What type of file is my_line? Commented Jun 16, 2014 at 0:46
  • It is a vector layer created using layer = QgsVectorLayer('LineString', 'my line' , 'memory') and QgsMapLayerRegistry.instance().addMapLayers([layer])
    – wannik
    Commented Jun 16, 2014 at 1:04
  • 3
    An in-memory layer is not persisted. You need to save it as a shapefile or other file system type. They are intended only as a temporary storage for processing etc. Commented Jun 16, 2014 at 1:12
  • @MichaelMiles-Stimson Thank you very much for the info. I'm now able to save the vector.
    – wannik
    Commented Jun 16, 2014 at 1:34
  • You're welcome. I'll turn that into an answer in case anyone else encounters this problem. Commented Jun 16, 2014 at 1:37

1 Answer 1


In memory layers are temporary, they don't get saved when you call save edits. They are only intended to be temporary and should be saved as a file system type (like shapefile) if you intend to keep their edits.

You should probably call QgsVectorLayer::setCoordinateSystem() on the layer before editing and definitely before saving. All spatial data should have a coordinate system, even if you make it the same as the canvas.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.