I know text annotations can be turned on & off with Ctrl+T... but is there any way to export them as a layer?

1 Answer 1


Since there doesn't seem to be an answer, here's my effort:

  1. Save your existing map, including existing text annotations.
  2. Delete all the layers, leaving a white screen, and the text annotations. Save it as something else, e.g. "only_labels"
  3. Close Qgis
  4. Open "only_labels.gqs" with a text editor. Notice the html/xml style format and that the text annotations have their own entries: . Within that there's an and within that mapPosX="" and mapPosY="", with the long/lats in the quotes.
  5. Since I don't know how to use xml data, I copied all the AnnotationItems and pasted them into Excel (libreoffice) in one long column
  6. Then added a counter column in front of that and trend filled from 1,2,3 to the end (I have a lot of labels). This allows me to reintegrate everything later.
  7. Then sorted everything by column B (the data)
  8. Then deleted all rows not beginning "TextAnnotationItem document=" or "AnnotationItem frameHeight=" (this removes all the junk. All we want are lat/longs & place names. I had to remove triangular brackets to post this).
  9. (I added a row at the top for labels, hence B2 not B1. Do the same just so you can easily copy paste) In column C, right of the AnnotationItem frameHeight rows, insert this formula: "=RIGHT(LEFT(B2,(FIND(" canvasPosY",B2)-2)),(FIND(" canvasPosY",B2)-2)-(FIND("mapPosX=",B2)+8))"
  10. In column D, this formula: "=RIGHT(LEFT(B2,(FIND(" frameColorAlpha",B2)-2)),(FIND(" frameColorAlpha",B2)-2)-(FIND("mapPosY=",B2)+8))"
  11. That's your X & Ys. Copy those formulae down all the AnnotationItem frameHeight rows.
  12. Right of the first TextAnnotationItem in Column F, paste this formula (which starts at row 103 for me, so change it to yours): "=LEFT((RIGHT(B103,LEN(B103)-(FIND(">",B103,FIND("pt;",B103,FIND("span style",B103)))))),(FIND("&lt",B103,FIND("pt;",B103,FIND("span style",B103)))-1)-(FIND(">",B103,FIND("pt;",B103,FIND("span style",B103)))))"
  13. Copy that down to all TextAnnotationItem cells
  14. Select all data, sort by counter (see item 6). It should now be alternating between TextAnnotationItem and AnnotationItem, starting with the former.
  15. Make cell E3 equal cell F2 (i.e. hit equals then click cell F2), this puts the location name right of the X & Y, on the same row.
  16. Copy that formula all the way down column E.
  17. Just to be safe, copy the lot & paste as value to a new sheet.
  18. Sort by the data (column B)
  19. Delete all the TextAnotationItem rows at the bottom
  20. Delete columns A & B, Move column C (place names) to the front, tidy any of the names up if required, save as a csv file, open in Qgis, have a beer and wish that this could be done automatically!
  • 1
    your question is really interesting, I'll try your answer. A little shortcut in the beginning is just using the base .qgs (no need to remove layers or copy the file) and extract directly the AnnotationItems
    – Dariopnc
    Commented Mar 10, 2014 at 14:53
  • hey, yeah! good shortcut!
    – dez93_2000
    Commented Mar 10, 2014 at 18:09
  • @dez93-2000 hi. Since QGIS 3.20 version it is possible to convert dynamic labels to static text, but only in the Print layout mode. See changelog qgis.org/ru/site/forusers/visualchangelog320/…
    – KVO
    Commented Aug 7, 2021 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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