<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font size="4">Hi Harrissou,<br>
         YES !  You've solved my problem and taught me something I knew
      nothing about.  <br>
      Many thanks.</font><br>
    <font size="5">Steve</font><br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 6/10/2023 8:57 PM, Harrissou s.
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:99B82E9C-1AAC-44A1-A7E3-61CEED48162E@gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="auto">Hi Stephen,<br>
        You seem to have fallen in the annotation layer "trap" [0].
        There is no layer behind and polygon deletion is mentioned in
        the docs I pointed to. Basically, select it with the "modify
        annotations" tool on the same toolbar, and press Del.<br>
        <br>
        To create regular polygon feature, you have to select the layer,
        turn it into edit mode and use digitizing tools. Read [1].<br>
        <br>
        Hope that helps.<br>
        Harrissou<br>
        <br>
        [0] <a
href="https://docs.qgis.org/3.28/en/docs/user_manual/map_views/map_view.html#interaction"
          moz-do-not-send="true" class="moz-txt-link-freetext">https://docs.qgis.org/3.28/en/docs/user_manual/map_views/map_view.html#interaction</a><br>
        [1] <a
href="https://docs.qgis.org/3.28/en/docs/user_manual/working_with_vector/editing_geometry_attributes.html#digitizing-an-existing-layer"
          moz-do-not-send="true" class="moz-txt-link-freetext">https://docs.qgis.org/3.28/en/docs/user_manual/working_with_vector/editing_geometry_attributes.html#digitizing-an-existing-layer</a></div>
      <br>
      <br>
      <div class="gmail_quote">
        <div dir="auto">Le 11 juin 2023 01:22:43 GMT+02:00, Stephen
          Sacks via QGIS-User <a class="moz-txt-link-rfc2396E" href="mailto:qgis-user@lists.osgeo.org"><qgis-user@lists.osgeo.org></a> a
          écrit :</div>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;"> <font size="4">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?   <br>
            ========================<br>
            from qgis.core import QgsProject<br>
            from qgis.utils import iface<br>
            <br>
            project = QgsProject.instance()<br>
            for lyr in project.mapLayers().values():         <br>
                lyrName = lyr.name()<br>
                print (lyrName)<br>
                QgsProject.instance().removeMapLayers([lyr.id()]) <br>
            <br>
                <br>
            <br>
          </font> </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>