Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


share|improve this question
up vote 1 down vote accepted

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!
share|improve this answer
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 Mar 10 '14 at 14:53
hey, yeah! good shortcut! – dez93_2000 Mar 10 '14 at 18:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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