When a layer is added to QGIS, it is ordinarily added to "Layers" panel and "Map Canvas". The same thing happens when a memory layer (loaded/created by QgsVectorLayer
) is added using QgsProject.instance().addMapLayer
.
layer = QgsVectorLayer("Polygon?crs=EPSG:4326", "Buffer", "memory")
#
QgsProject.instance().addMapLayer(layer) # after this line, layer is added to both area.
When writing a script step by step, I usually add intermediate layers to control if the script runs correctly. Then I need to remove them manually and repeatedly.
I want a layer which I add to memory to be added to "Map Canvas" only. How can I achieve that? Is it possible to break the connection between "Layers" panel and "Map Canvas".
For example, as shown in the image, I want Buffer
layer to appear only in "Map Canvas", but not in "Layers" panel.