[GRASS-user] Having trouble getting integer labels

Hamish hamish_nospam at yahoo.com
Tue Jun 6 09:13:56 EDT 2006


> Paul Pick wrote:
> > I have a bunch of (integer) point data I'm trying
> > to contour. I've done v.in.ascii, v.surf.idw, and
> > r.contour. The output vector (the contour shapes)
> > has a 'level' attribute which is a double.
> >
> > $ v.info v500contour -c
> > Displaying column type for database connection of layer 1:
> > INTEGER|cat
> > DOUBLE PRECISION|level
> >
> >  When I create labels for those contours (with v.label),

[same with "d.vect disp=attr" (try it) or d.what.vect]

> > I'm getting six zeroes after the decimal. I really need
> > to display only integer labels, so how should I go
> > about that?
> >
> >  I'm running GRASS 6.0.0 on debian sarge.

Dave Kent wrote:
> I have not been able to figure out how not to generate a label file  
> with 6 significant figures.
> 
> You can however edit the Location/paint/labels/Label_File text file 
> with search and replace all  ".000000" to "" which removes the  
> trailing zeros from the 'text:  540.0000000 entires'

The labels file is really easy to edit. I think tweaking the offsets by
hand in a parallel editor + d.redraw is probably the best way of getting
things "just right". (my logic is too fuzzy to implement Fuzzy Logic)


Anyway, you won't have to worry about trailing zeros in the future, I've
just updated db_convert_value_to_string() in lib/db/dbmi_base/valuefmt.c
to use G_trim_decimal() if it's a DOUBLE column type. This will affect
d.vect, d.what.vect, v.label, v.db.select, db.select, and probably some
other places in the select & form areas. Hopefully with no ill effects;
it is trimming back from %lf so parts like .000000014 won't be chopped
away in err.

Also, FWIW, GRASS 5's d.site.labels has a precision= option for this.


Hamish




More information about the grass-user mailing list