8

I am trying to determine the maximum number of characters for a label in QGIS 3. I am at over 1,000 characters and it does not display. Is there another way to display text on a map with a large number of characters - text box, etc.?

enter image description here

City    Latitude    Longitude

Some City 51.500210 -0.126280 Second City 48.852421 2.351008 Third City 48.211534 16.384351 Fourth City Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. N 45.438171 12.334102 Florence 43.769019 11.250152

0

2 Answers 2

8

After experimenting a little bit, I can confirm that QGIS has definitely no limitation of 1000 characters or less (as the initial form of the question suggested). Empirical evidence suggests that the limit of characters for a label is 2^15 - 8 = 32.760 characters - if pasted directly in the label field. If the label is based on an attribute, potential limits in the field length of the data format of the layer's source (file or database) apply.

See my screenshot, where I pasted a blindtext created in Word and counted as 17.016 characters (!). As you can see, the text displays as a label of the point in the bottom left of the map canvas.

I also tried longer labels. An empirical value where QGIS clipped the text at the end was reached with 32.760 characters (near 32.768 = 2^15). So you could include a shorter term paper inside of a label text. That sayed means that the limitations are definitely more on the side of visualization, as MrXsquared already mentioned in his comment, than technical abilities of QGIS. QGIS is definitely able to display really very, very long labels.

The problem in your case has been another one (solved in anotoher answer). In any case, always make sure when using a field name as label if the data provider format has some limitations. I pasted the text directly with simple quotation marks : ', thus not using the content of an attribute field. So we really speak here about label length, not lenght of field content - we have to clearly distinguish between them.

What you also have to be aware of is line wrapping. Maybe when lines get too long (or when the labeled geometry feature is not visible on the map canvas) the label does not render. See this answer here: https://gis.stackexchange.com/a/381205/88814

enter image description here

Labels of such a length are definitely not established practice - a label with 30 (!) characters is already characterized as "very long":

Sometimes labels are very long, such as "River of the Big Dry Blue Reef"

It would be interesting what you want to use such long labels for. Or is it just curiosity for the technical limitations of the feature?

For (dynamic) webmaps, anyway the placement of the labels changes with every zoom level (and panning), so I would use pop-ups, have a look at actions.

For print output, in Print Layouts and Reports, you have textfields at your disposal.

10
  • Thanks so much for the input! It is great to know of what you found and that 1000 characters works. I will look at the other areas you mentioned. The application involves a guided tour will sometimes much reading at different stops.
    – bdelliott
    Commented Dec 15, 2020 at 15:01
  • I am trying to create the points and labels from a tab delimited file (qgistutorials.com/en/docs/importing_spreadsheets_csv.html). But in trying to reproduce your test case above with the 1000 characters I am having trouble because I am new to QGIS. Is there any way to make it data-driven from a file? How did you create your layer - temporary scratch layer and manually add points?
    – bdelliott
    Commented Dec 20, 2020 at 18:35
  • Yes, I guess it was a temporary scratch layer with manually added point.
    – Babel
    Commented Dec 20, 2020 at 19:36
  • And yes: you can add a CSV to QGIS containing fields with long strings (testet: 2000) that are displayed when you select it. However, I had to disable the labeling of nearby points, otherwise it didn't show because QGIS tries to avoid overlapping labels.
    – Babel
    Commented Dec 20, 2020 at 19:53
  • Thanks - I will give it a try again - both ways manually and with a CSV
    – bdelliott
    Commented Dec 22, 2020 at 15:18
3

Update to the updated question that includes your CSV: The problem with your CSV is that you have an N in front of latitude: N 45.438171. Like this, QGIS can't recognize this value for latitude and does not create a point. This has nothing to do with the length of the text, as your initial question suggested (and why my first answer focused on this aspect).

Be sure to use an unambiguous delimiter, not a space to delimit the fields - in the text you pasted, I'm not sure what character you used. Use a character that is not represented anywhere in your label texts, thus no space, point, comma etc. Than it works fine, see my try where I used semicolon: ;. You can save this code as csv and import it to QGIS, see the output with labels on the screenshot (use word wrap to see the whole text):

City;Latitude;Longitude
Some City;51.500210;-0.126280
Second City;48.852421;2.351008
Third City;48.211534;16.384351
Fourth City Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum.;45.438171;12.334102 
Florence;43.769019;11.250152

enter image description here

1
  • My fields were tab delimited so I thought a space in font of the N would not matter. But I had an extra tab on the 4th line that messed up the label. I fixed that and it worked fine! But to your point to use a character that is not represented elsewhere, I switched to a pipe ("|") and got that working as well! So now I am good! Thanks so much!!!
    – bdelliott
    Commented Dec 27, 2020 at 21:42

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.