[GRASS-user] Label difficulties

Adam Dershowitz adershowitz at exponent.com
Tue Aug 28 01:40:34 EDT 2007

On Aug 27, 2007, at 9:39 PM, Hamish wrote:

> Adam Dershowitz wrote:
>> I am trying to work with a map that has multi-line vector labels,
>> over a raster basemap.  I have tried it a few different ways and run
>> into different problems with each.
>> I am using the 6.3 binary by William Kyngesburye on  Mac.
>> First I just tried adding the two characters "\n" to the labels, then
>> ran v.label.
>> If I then add a raster label layer it does go over several lines, and
>> all looks correct.  The problem is when I try to save it to jpg and
>> print it that the text is too "pixelated" and looks terrible (also
>> looks the same if I save it to a pdf).  I tried changing the
>> resolution with g.region, but it did not seem to have any effect.
>> The current region is set to the resolution of the actual raster
>> basemap, so maybe that is why?
> My guess is that the crummy looking fonts is the result of a  
> limitation
> in the PS driver, although Michael might be able to confirm that.  
> If it's
> worth anything, the PNG driver actually makes the fonts look nicer  
> than
> on the xmon displays. (GUI canvas has the nice version)
> What save display as.. JPEG format did you use? 95%? does the JPEG  
> look
> ok on the screen but it not print nicely?

I just tried out the PNG, and it looks about like the JPEG.  I had  
been saving the JPEG at "very high resolution (300% your current  
resolution)"  I think that the issue is that both look a bunch like  
the screen.  But if I zoom on the screen the label font size changes  
and uses an appropriate number of pixels so that it looks good.  But  
if I print the whole thing and then try to read the labels, they are  
pretty small and seem to be drawn with 5x7 pixels or so.  In other  
words they look like an LED display or something.

> Worst case you could take a screenshot of what you see in the display
> window and clean that up using Gimp or your favorite paint program.

Essentially what I need is for the text to be higher resolution then  
the screen, even though the basemap is fine at the current  
resolution.  So that won't really help.

>> Next I tried adding a postscript label layer instead.  That layer
>> looks good on the screen and when saved to a PDF, in terms of the
>> resolution.  The problem is that the "\n" in the text is showing up
>> explicitly, as those two characters, rather then causing a new line
>> in the labels.  So the labels have these extra characters and break
>> in odd places.  This is the case both when viewing this layer in the
>> Map display and the saved version.
> My guess is that is an oversight in that tool which hasn't been
> programmed in yet. '\n' should be processed by it into a newline.
> It's in gui/tcltk/gis.m/maplabels.tcl  ~ line 433:
> proc GmCLabels::display {}
> ...
> 	"text" {
> 		set opt($id,1,ltxt) $val
> maybe a way to process the text string with formatting codes to  
> newlines
> automatically? (tcl is string friendly, so search and replace  
> shouldn't
> can't be too hard, although I've no idea how)
> % set a {1\n2}
> 1\n2
> % set a "1\n2"
> 1
> 2
I might try to look into that.

> Probably the linewrap and border box code in there needs updating too.
>> So my main question is how can I get good quality multi-line labels
>> to a saved file?  Is there a way to cause the font resolution to be
>> higher in my raster layer?  Is there a way to get a vector layer to
>> break across multiple lines where I want?  Is there some other
>> solution that I am missing?
> You might try ps.map or d.* commands directly on the command line,  
> they
> might not be as user friendly as the GUI, but they are more mature and
> IM(biased)O ps.map creates the best looking output.

I might try to work it out that way.  Although I wonder if ps.map  
will correctly handle a multi-line labels with the \n in them?  Or  
will I end up with the same problem?  It also looks like ps.map can  
only take a single raster map, when I am currently using two maps  
that are overlayed.  I will have to do that by hand as well, but I  
suppose it can be done.

> Hamish



More information about the grass-user mailing list