[Qgis-user] Multi-line labels and field calculator

Andrew Chapman andrew.chapman at donkagen.co.uk
Sun Oct 23 07:55:07 PDT 2011


Hi Alexander,
In my case the problem was the destination text attribute had a field width
shorter than the output string and so was truncating. I edited the field
width in Open Office Calc and then everything worked ok.
Are there any descriptions anywhere about how to use the expression based
labelling and/or what valid expressions can be used in the field calculator.
The field string I used was determined by trial and error, so I'm assuming
that there is a lot more that can be done with this tool.

Andrew 

-----Original Message-----
From: Alexander Bruy [mailto:alexander.bruy at gmail.com] 
Sent: 23 October 2011 15:44
To: Andrew Chapman
Cc: qgis-user at lists.osgeo.org
Subject: Re: [Qgis-user] Multi-line labels and field calculator

Hi Andrew,

DBF which is used s attribute storage in shapefiles has several limitations.
Among them — maximum text length is 255 symbols. So if your text
is longer than 255 chars, it will be truncated.

You can load your data into PostGIS or SpatiaLite databases where text
can be much longer that 255 chars. Or alternatively, you can use new
expression based labeling which is available in master.

Hope this helps

2011/10/23 Andrew Chapman <andrew.chapman at donkagen.co.uk>:
> I'm trying to combine multiple attributes into a single multi-line
> equivalent to use as a label in a shapefile.
> I create and populate a new attribute using the field calculator using an
> expression like:
>  stringField + '\n' + '(' + to string(decimalField) + ' some text'
> This successfully creates a multi-line string in the target field PROVIDED
> THAT I DON'T SAVE THE FILE. I can then use the new symbology text to
display
> the expected label.
> If I save the layer, the multi-line string is truncated to the first line
> only and the displayed label reverts to the first line.
> The multi-line string therefore isn't saved. Is this a limitation of
> shapefiles or is it a bug?
> If it is a limitation of shapefiles, is there any other way to achieve the
> same effect?

-- 
Alexander Bruy


-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1831 / Virus Database: 2092/4568 - Release Date: 10/22/11





More information about the Qgis-user mailing list