[Qgis-user] mysterious polygon

Stephen Sacks ssacks456 at gmail.com
Sat Jun 10 16:22:43 PDT 2023


My intention was to create a new vector layer consisting of several 
polygons.  I used the CreatePolygon tool to mark the four vertices of a 
rectangle.  I must have done something wrong because I've ended up with 
a polygon that seems to belong to no layer.   In desperation I ran the 
following python code, hoping to delete the mysterious polygon, but it's 
still there.  Are some layers not in the legend?  How do I  get rid of 
the   polygon?
========================
from qgis.core import QgsProject
from qgis.utils import iface

project = QgsProject.instance()
for lyr in project.mapLayers().values():
     lyrName = lyr.name()
     print (lyrName)
     QgsProject.instance().removeMapLayers([lyr.id()])


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230610/01ff748a/attachment.htm>


More information about the QGIS-User mailing list