[GRASSLIST:10134] Display labels as integer only

I have a vector points file and I have labels for each point derived from a floating-point attribute. Is it possible to display the labels as integer only? For instance I have labels like 253.230000 and all I want is 253. Or is there a way to convert the attribute to integer?

Thanks
--Mike

On Thursday 02 February 2006 04:44 pm, Michael Peterman wrote:

I have a vector points file and I have labels for each point derived
from a floating-point attribute. Is it possible to display the labels
as integer only? For instance I have labels like 253.230000 and all I
want is 253. Or is there a way to convert the attribute to integer?

Thanks
--Mike

echo "alter table xxx add column new_label int" | db.execute
echo "update table set new_label = old_label" | db.execute

i know that this works with MySQL as an attribute storage DB, not sure about
the DBF method- but is is worth a try!

Cheers,

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

Hi Dylan,
thanks for helping out. The first line works but the second one returns an error:
SQL parser error in statement: update table points set mx_int = MX

Error in db_execute_immediate()
....

--Mike

Dylan Beaudette wrote:

On Thursday 02 February 2006 04:44 pm, Michael Peterman wrote:

I have a vector points file and I have labels for each point derived
from a floating-point attribute. Is it possible to display the labels
as integer only? For instance I have labels like 253.230000 and all I
want is 253. Or is there a way to convert the attribute to integer?

Thanks
--Mike
   
echo "alter table xxx add column new_label int" | db.execute
echo "update table set new_label = old_label" | db.execute

i know that this works with MySQL as an attribute storage DB, not sure about the DBF method- but is is worth a try!

Cheers,

Well this is a bit of a kludge: I used sed on the /paint/labels file.

sed '/text/s/\.[0-9]*//g' < labels > labels_int

which just chops off everything after the decimal. Not a great solution, but good enough for now.

I'm not very skilled in sql but, did you try
update table points set mx_int=int(MX)

Daniel

On 2/6/06, Michael Peterman <michaelp@sjgeophysics.com> wrote:

Hi Dylan,
thanks for helping out. The first line works but the second one returns
an error:
SQL parser error in statement: update table points set mx_int = MX

Error in db_execute_immediate()
....

--Mike

Dylan Beaudette wrote:

On Thursday 02 February 2006 04:44 pm, Michael Peterman wrote:

I have a vector points file and I have labels for each point derived
       
from a floating-point attribute. Is it possible to display the labels
     
as integer only? For instance I have labels like 253.230000 and all I
want is 253. Or is there a way to convert the attribute to integer?

Thanks
--Mike

echo "alter table xxx add column new_label int" | db.execute
echo "update table set new_label = old_label" | db.execute

i know that this works with MySQL as an attribute storage DB, not sure about
the DBF method- but is is worth a try!

Cheers,