Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
    
What type of file is my_line? –  Michael Miles-Stimson Jun 16 at 0:46
    
It is a vector layer created using layer = QgsVectorLayer('LineString', 'my line' , 'memory') and QgsMapLayerRegistry.instance().addMapLayers([layer]) –  wannik Jun 16 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. –  Michael Miles-Stimson Jun 16 at 1:12
    
@MichaelMiles-Stimson Thank you very much for the info. I'm now able to save the vector. –  wannik Jun 16 at 1:34
    
You're welcome. I'll turn that into an answer in case anyone else encounters this problem. –  Michael Miles-Stimson Jun 16 at 1:37
add comment

1 Answer 1

up vote 7 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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