Hi, Am 03.02.2012 um 17:30 schrieb Micha Silver: > On 02/03/2012 01:57 PM, Johannes Radinger wrote: >> >> Hello, >> >> While working on a vectorfile (lines) with 46000 entries in sqlite in GRASS >> some questions popped up: >> >> 1) Somehow my cat column is double precision instead of integer...Can it be >> transformed into an integer within GRASS GIS to do some v.select operations >> with it? If yes, how exactly? > > Converting the values to integer can be done with the sqlite CAST(cat AS > integer). But that probably won't help. THe column itself needs to be integer > type, so I think you need to make a new cat column and populate it with > integer values: > Using sqlite: > sqlite> alter table <your vector> add column cat2 integer; > sqlite> update <your vector> set cat2=CAST(cat AS integer);
Thank you for that, but what should I use to call sqlite commands? Can that be done inside GRASS, is there any tool? Or should that be done from any sqlite-management software or from any command line programm (GRASS console? Mac Terminal?) > >> >> 2) Is it possible to change the order of the columns in the attribute table? > > In sqlite you can't change the order of the columns, so you'll need to create > a new table ordered the way you want, then juggle the table names so that the > grass vector "sees" the new reordered table. > Suppose, after the first question above you have a vector with columns: > cat double, label text, value double, cat2 integer > and you want the reordered table to be: > label, value, cat (the new integer one) Of course it is not necessary to change the order for database calls etc. It would just be interesting when I look into the attribute table of a vector within GRASS I have to scroll to the very far rigtht side to get to e.g. my vector name label which is not that comfortable for a quick view... Therefore a quick sort (drag and drop) within the GRASS GUI would be of nice but not necessary of course... > > then: > > sqlite> CREATE TABLE tmp (label text, value double, cat integer); > sqlite> INSERT INTO tmp (label, value, cat) SELECT label, value, cat2 FROM > <your_vector>; > sqlite> ALTER TABLE <your_vector> RENAME TO vector_bak; > sqlite> ALTER TABLE tmp RENAME TO <your_vector>; > > HTH, > Micha > >> >> I am working on GRASS GIS 6.5SVN on Mac OSX. >> >> Best regards, >> Johannes > > > -- > Micha Silver > GIS Consultant, Arava Development Co. > http://www.surfaces.co.il
_______________________________________________ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user