[GRASSLIST:857] Re: v.segment

Michael Barton michael.barton at asu.edu
Tue Apr 25 02:48:14 EDT 2006


Trevor,

If you've got the cat values from v.build the main issue is to get them into
something that GRASS can recognize as an attribute table. You could simply
import them into a spreadsheet and export them as dbf. Then use
v.db.connect. Even better if there was a txt2dbf utility. Maybe someone
knows of one. Or you could try a MySQL or SQLite routine to get the data
into one of those formats.

However, if you want to script this you might try the following:

Redirect the stdout to a file datafile.csv
I think you'd need to add a field name line to the beginning
Replace all the "|" with "," using sed
Use v.in.ogr to read in the csv file
Use v.db.connect to the new attribute file.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton



> From: Trevor Wiens <twiens at interbaun.com>
> Date: Tue, 25 Apr 2006 00:26:41 -0600
> To: Michael Barton <michael.barton at asu.edu>
> Cc: Multiple recipients of list <grasslist at baylor.edu>
> Subject: Re: [GRASSLIST:855] Re: v.segment
> 
> On Mon, 24 Apr 2006 23:00:15 -0700
> Michael Barton <michael.barton at asu.edu> wrote:
> 
>> Use v.category to attach categories.
>> 
>> V.to.db to add information to attribute table? I don't know if this works
>> with v.segment output or not. In fact, I can't figure out how v.segment
>> works either.
>> 
>> Create a dbf file using a spreadsheet (OO or Excel -- OO works better). Call
>> the first column "cat", make it an integer, and fill it with a sequence of
>> numbers equal to the number of points you have. Then use v.db.connect to
>> link them up.
>> 
> 
> Michael,
> 
> Thanks, but not really what I wanted to hear.
> 
> I wrote a script to make stops on Breeding Bird Survey route lines at
> equal intervals, and manipulated the category values to be meaningful.
> 
> Unfortunately, v.segment doesn't create an attribute table so I used
> v.build with the cdump option to get a list of the categories and then
> used db.execute to add them one by one into a table. Very slow.
> 
> I can see now I could get a list easier using v.category, but
> unfortunately it won't automagically create an attribute table with the
> categories in it.
> 
> I was hoping for an easy way to do this as it would make the script a
> lot more elegant and faster, but it appears that my ugly hack is the
> only solution.
> 
> Thanks
> 
> T
> -- 
> Trevor Wiens 
> twiens at interbaun.com
> 
> The significant problems that we face cannot be solved at the same
> level of thinking we were at when we created them.
> (Albert Einstein)




More information about the grass-user mailing list