It's impressive how many different vector file formats QGIS (using ver 3.6.0) allows me to save a layer as:

QGIS save vector layer as...

But as far as I can tell, QGIS doesn't allow me to save a vector layer to memory. In my normal workflow in manipulating vector layers, I find myself having to save several intermediate vector layers to file, clogging up my file system or databsase with something like "vector_layer", "vector_layer1", "vector_layer2", "vector_layer2a", etc. It is often trivial to perform the updates/edits to the layer, and because I really don't care about these intermediate files, I'd rather be able to just save them in memory within the QGIS environment. Saving to memory would allow me to simply remove the layers from the project when I finish my workflow instead of having to delete from my Postgres database or my desktop.

When performing a geoprocessing task, there is the option to save to memory, but why can't I have the option to export a layer to memory on its own?

  • I don't get why you are not using those temporary/virtual (memory) layers produced by e.g. the geoprocessing tools; they are, effectively, 'saved to memory'? they are pretty much exactly what you refer to: in-memory (or stored in the QGIS temp directory, kept there until deleted after saving the project), reusable in other tools in the chain and easily disposed of (cluttering only your layer panel, but that can be grouped accordingly)...or am I not getting your question? 'save to memory' is somewhat of a paradox...
    – geozelot
    Apr 12, 2019 at 11:00
  • You can request a feature: issues.qgis.org.
    – csk
    Apr 12, 2019 at 19:50
  • @ThingumaBob - maybe "store to memory" is bit more accurate than "save to memory". Like you say, there is no problem storing to memory if using any of the geoprocessing tools. However, that isn't what I am trying to do. I was asking about the option to simply store to memory using the "Export" option.
    – Tyler N
    Apr 15, 2019 at 17:58
  • @TylerN I know that you asked for export, and I actually didn't know the GDAL virtual env is available from within QGIS. ...the purpose is puzzling me. make those layers available to other software?
    – geozelot
    Apr 15, 2019 at 18:26
  • @ThingumaBob A common use case for me is to make a copy of a layer to do some edits to the attribute table. I don't necessarily want to make edits on the original data layer because I might risk overwriting/losing my original data. Also, I don't necessarily want to make a copy (or multiple copies) because it clutters up my file directory or database (after all, they are usually intermediate/temporary layers).
    – Tyler N
    Apr 15, 2019 at 18:36

3 Answers 3


Try outputting a specific format to memory using the special "/vsimem" virtual filesystem.

For example:

enter image description here

enter image description here

  • This option works and achieves what I am after. However, I still have to choose a file format, which seems to be meaningless from the end user perspective (I'm sure it's necessary from a storage/driver perspective). Also, I have to physically type "/vsimem/" which obviously isn't a big deal, but perhaps not the most ideal. Something I wonder is why vsimem isn't its own option in the "Format" dropdown (defaulting to some well known, generic format like geojson)? Probably a QGIS feature request.
    – Tyler N
    Apr 15, 2019 at 18:31

As a workaround, you can copy a layer to memory by running a processing tool in a way that generates an identical layer, and output the tool to [Create temporary layer].

For example, use the default $geometry expression in the Geometry by expression tool:

enter image description here

Other options include:

  • for polygon layers, Buffer tool with buffer distance of 0
  • Translate tool with all offset distances 0
  • Reproject Layer tool with Target CRS the same as the layer's current CRS


  • This option definitely achieves what I am after and works for me. It just requires that I rename my layer after the "dummy" geoprocessing. Ideally, I'd like to choose the name and still store to memory.
    – Tyler N
    Apr 15, 2019 at 18:25

Less an answer, but mere suggestions in the more flexible direction of SQL, as I personally think that the need for what you describe might be a hint to change your workflow (no offense), at least within the QGIS/PostGIS environment...

  • use the SQL GUI:
    since you explained a common task is manipulating the attributes (without necessarily saving the results), work with the DB Manager. Next to a full scale PostgreSQL/SpatiaLite client, the DB Manager provides the full SpatiaLite SQL interface for all project layers.

    Run queries to aggregate or analyze the attributes, stack queries to work with intermediate results, view them live in the GUI and load them as (memory) layers for further geoprocessing if needed (this works with simply copying the base layer, too).

  • use Virtual Layers:
    similar to the features and handling from above, the Virtual Layers are flexible and multi-source instances of memory layers that are defined and manipulated with SQL.

    Add a Virtual Layer, define it's sources and manipulate its data as needed, with the power of SQL just as above. Use it in further geoprocessing, save it's definition to .qlr and reuse it in other projects.

  • use Views:
    on DB level, simply save your queries as Views and load them into QGIS.

    Again, as above, you can view (no kidding) the results of queries just as with other layers, and use its 'data' in further geoprocessing, save to file or whatever. You can't and/or shouldn't edit in QGIS itself, though, without a bit of a setup in the DB.

The Virtual Layers can actually combine all these; you can add literally any data source supported in QGIS to its sources, and switch sources as needed. All these options effectively save to memory, with a name of your choice...

I work with this stack a lot, and I honestly can't remember the last time I used the export.

  • I wasn't really aware of Virtual Layers, but as far as I can tell at this point, virtual layers effectively address any of the issues that would have been desired by "exporting/storing to memory". Another plus, they seem to be able to do much more than I ever imagined. Thanks a lot for the tips!
    – Tyler N
    Apr 22, 2019 at 22:26

Your Answer

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

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