6

Context

I have always worked with memory outputs from several QGIS geoalgorithms within the Processing Toolbox. If it wasn't specified a location when saving the result, the output was stored as a temporary layer in a specified path, which was in general something like:

C:\Users\xxxxx\AppData\Local\Temp\processinge252173536ab4ef987fcb13829939857\c35bd5c897f24c5eb13b9aad985b9652\OUTPUT.shp

If the temporary layer wasn't saved before quitting QGIS, it was automatically deleted from the disk.

Issue

Using QGIS 2.18, I casually noted that I'm no longer able to find the temporary output layers in the Temp folder: this behavior appears to only belong to the QGIS geoalgorithms (instead, the temporary outputs from SAGA or GRASS algorithms are still saved in the Temp folder, as usual).

If I select one output from the QGIS geoalgorithms and go to Properties > General, I see something like this in the Layer source field:

Polygon?uuid=29cdbb21-d299-4b01-b735-0004971e1203&crs=EPSG:32632&field=id:integer&field=value:string&field=area:double&field=perim:double

As you can see, there isn't any reference to a path in my disk, so I can't find the physical position of the output.

In Settings > System, I have this path for the temporary files:

C:\Users\xxxxx\AppData\Local\Temp

In the Processing options, instead, I have:

C:\Users\xxxxx\.qgis2\processing\outputs

There is something that I don't know on how the temporary output layers are managed since the current version of QGIS? I encountered this issue using QGIS 2.18, but I don't exclude that it could be started from previous versions of the software.

  • Try C:\Users\xxxxxxx\ .qgis2\processing\outputs – user108769 Nov 8 '17 at 21:16
  • Remove space before .qgis2 – user108769 Nov 8 '17 at 21:18
  • You should be able to edit your own post. One line posts are discouraged. Is there anything you can add? – Mattropolis Nov 8 '17 at 21:54
  • I just want to comment that I ran a processing algorithm that projected a layer present in the canvas [processing.runandload("qgis:reprojectlayer",layer, "epsg:4326", "projected")], a new layer was added to the canvas named "Reprojected", I was not sure if it was memory layer or temporary layer, all I knew was that in properties it displayed as layer source "projected.shp" without any other path in opposition to the original layer whose source was "D:/PracticaQGisPlugins/Data/MSCities_MSTM.shp". I searched the folders where it should have been to no avail, finally I found it in C:\OSGeo4W\bin – nanunga Jun 17 '18 at 1:27
  • I must add that I am running QGIS 2.18.20 32 bits, Windows 7 64 bits. And also that with the following python command (myfilepath= layer.dataProvider().dataSourceUri()) I obtain the following result in the python console: Reprojected projected.shp|layerid=0 MSCities_MSTM D:/PracticaQGisPlugins/Data/MSCities_MSTM.shp|layerid=0 – nanunga Jun 17 '18 at 1:31
5

As @ndawson correctly commented:

They weren't memory layers, they were just shapefiles stored in a temporary location (and subject to all the limitations present in the shapefile format!)

The final note is that the name "memory layer" was improperly used.

4

The layer with the URL starting 'polygon:' is a memory layer (or 'scratch' layer). You can create one yourself using Add layer > New temporary scratch layer. As it's in memory, it's not written off to disk (unless you decide to do this manually using save as..) and will vanish once you close QGIS.

According to the docs (emphasis mine)

Memory provider is intended to be used mainly by plugin or 3rd party app developers. It does not store data on disk, allowing developers to use it as a fast backend for some temporary layers.

Recent versions of QGIS' Geoalgorithms default to writing to "new temporary layer" if you don't specify a filename in the pull-down menu (the ... button) so you can always save the intermediate steps in your process if you want

GRASS and SAGA don't understand memory layers, as far as I know, so they continue to write to /tmp

You can access memory layers like any other layer, query against them as virtual layers etc.

  • Thanks @StevenKay for the clarification! You added more informations about the using of memory layers, but all these ones are already knew by me. My question is more specific because, in the previous QGIS versions, even the memory layers from the QGIS geoalgorithms were saved in a temp (physical) folder in the .qgis2 path (as it still happens for GRASS or SAGA tools). My guess is why I can't get the same with newer versions... I hope it is clearer by now :) – mgri Feb 6 '17 at 18:48
  • 5
    They weren't memory layers, they were just shapefiles stored in a temporary location (and subject to all the limitations present in the shapefile format!) – ndawson Feb 6 '17 at 19:26
  • Thanks @ndawson... I think this clarification should be sufficient for satisfying my curiosity! ;) – mgri Feb 6 '17 at 20:22
  • So is there a difference between a "memory layer" and the "new temporary layer"? @Steven Kay – eyerah Jan 20 '18 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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