By David Crowther
What are Temporary Layers in QGIS and how do you use them?
In QGIS, when you run certain processing tasks, the resultant file can be output as a Temporary Layer. These are often referred to as Scratch Layers.
For example, we have just run the Add geometry attributes tool for my GIS Point layer (Hospitals) and the output from the processing task is a Temporary Layer which is a copy of the original file with the added attributes – now added to the map and denoted with the symbol below.
These are useful as they mean you can do your work in a QGIS Project, calculate your answer and you don’t need to keep saving multiple copies of GIS files. They are temporary layers in your current project session and won’t take up space on your PC.
Be wary though as these Temporary Layers won’t be saved in your QGIS Project and so will be lost when you close that project!
1 – Saving a Temporary Layer
If you wish to save a copy of a Temporary layer so that you can use it later or email to a colleague, then you can simply right click on the layer in the Layers Panel and choose Make Permanent.
Choose the format to save it as e.g. Shapefile, GeoPackage… and then give the layer a name and choose a location to store it within.
Press OK and a copy of the Temporary Layer has now been saved as a permanent GIS file.
2 – Creating a Temporary Layer
Temporary Layers are also useful if you want to quickly create some layers for analysis. For example, you may wish to run the Network Analysis – Shortest Path (Layer to Point) to find the quickest/shortest routes from a start location to a series of end points.
In our example, we have a GIS Layer that contains the starting Point location (the School address), but we don’t have a layer which represents just the 7 selected Pupils that we wish to measure to. To make this easy and save time - instead, of creating a permanent GIS file for the 7 Pupils or editing an existing file to remove the pupil records that you don’t want to measure to, you can quickly create a temporary layer of points representing just the required 7 start locations.
To do this, choose Layer > Create Layer > New Temporary Scratch Layer.
- Choose a Name for the Layer.
- Choose the Geometry Type e.g. Point.
- Add any fields needed e.g. Pupils Name.
You can then make the Temporary Pupil Layer editable and very quickly draw the Point locations within the map, representing the Pupil addresses to measure to.
Now when you run the Network Analysis – Shortest Path (Layer to Point) tool, you can choose the Temporary Layer (Pupil Locations) as the vector layer containing the end points.
By quickly creating a Temporary Layer to run this network analysis, we have managed to produce the output file that we need – the Shortest Path Lines – without having to create new permanent GIS files that will inevitably not be deleted from our PC!