[GRASSLIST:3984] how to access built-in vector attributes (GRASS 5.7)?

Or whatever they're called. Right now I'm looking at lines. When you d.what.vect, it shows cats, fields and attributes, and length and line height. I haven't checked polgons yet, but I'm guessing they have perimeter and area instead of length.

1. I would like to v.extract to extract lines above a certain length - ie weed out those short blips.

2. I want to export the lines with line height as an attribute. Not important now, but labelling lines with line height, using different colors... (not ready to mess with NVIZ yet, but maybe that's the only way?), or extracting certain line heights or ranges of heights.

I couldn't find any info on these 'attributes' - so I'm sot sure if they are something that can be queried or not.

-----
William Kyngesburye <kyngchaos@charter.net>
http://webpages.charter.net/kyngchaos/

"Time is an illusion - lunchtime doubly so."

- Ford Prefect

On Wed, Jul 21, 2004 at 03:59:41PM -0500, William K wrote:

Or whatever they're called. Right now I'm looking at lines. When you
d.what.vect, it shows cats, fields and attributes, and length and line
height. I haven't checked polgons yet, but I'm guessing they have
perimeter and area instead of length.

1. I would like to v.extract to extract lines above a certain length -
ie weed out those short blips.

You need to use v.to.db.

1. use db.execute create a new table:
  
Example:
  echo "CREATE TABLE roadlength (cat integer, linelength double)" | db.execute

  Link this table as second table to your map:

  #check current settings:
  v.db.connect -p roads2
  
  #link new table:
  v.db.connect m=roads2 dr=dbf data='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf' \
               key=cat table=roadlength field=2

2. Verify that the new tables exists now:

  v.info -c roads2
  v.info -c roads2 field=2

3. Generate new categories in the map:
  v.category roads2 out=roadsnew field=2 option=add
  v.category input=roadsnew option=report

  # should report something like this (for field=2):
  # type count min max
  # line 825 1 825
  # -> 825 lines in this map

4. Populate new attribute table with CATs for each vector line:
  (make it corresponding to map)

  v.to.db map=roadsnew field=2 option=cat type=line col1=cat

5. Upload line lengths of each vector line to attribute table:
  
  v.to.db map=roadsnew field=2 option=length type=line col1=linelength units=me

6. Check with
   
   d.erase
   d.vect roadsnew
   d.what.vect

7. Extract data (here: shorter than 2000meters):

   v.extract roadsnew out=roadsnew_short field=2 where="linelength < 2000"
   d.vect roadsnew_short col=red

Note: Initially you may want to use v.build.polylines to build polylines from lines.

2. I want to export the lines with line height as an attribute. Not
important now, but labelling lines with line height, using different
colors... (not ready to mess with NVIZ yet, but maybe that's the only
way?), or extracting certain line heights or ranges of heights.

... see above (now you should be able to do that).

Hope this helps

Markus

egads! that's a lot of work.

Actually, I was trying something similar, from bits here and there off the mailing list. I had trouble creating the DB at first. Then it looks like I missed the cat thing - I wasn't reclassing the cats to unique numbers, and I wasn't populating the db with the cats first. (Oh, why can't there be a simple one-for-one relationship between features and attributes, instead of messing around with this category stuff?)

On Jul 22, 2004, at 7:06 AM, Markus Neteler wrote:

On Wed, Jul 21, 2004 at 03:59:41PM -0500, William K wrote:

Or whatever they're called. Right now I'm looking at lines. When you
d.what.vect, it shows cats, fields and attributes, and length and line
height. I haven't checked polgons yet, but I'm guessing they have
perimeter and area instead of length.

1. I would like to v.extract to extract lines above a certain length -
ie weed out those short blips.

You need to use v.to.db.

.....

-----
William Kyngesburye <kyngchaos@charter.net>
http://webpages.charter.net/kyngchaos/

First Pogril: Why is life like sticking your head in a bucket filled with hyena offal?
Second Pogril: I don't know. Why IS life like sticking your head in a bucket filled with hyena offal?
First Pogril: I don't know either. Wretched, isn't it?

-HitchHiker's Guide to the Galaxy

On Jul 22, 2004, at 7:06 AM, Markus Neteler wrote:

On Wed, Jul 21, 2004 at 03:59:41PM -0500, William K wrote:

Or whatever they're called. Right now I'm looking at lines. When you
d.what.vect, it shows cats, fields and attributes, and length and line
height. I haven't checked polgons yet, but I'm guessing they have
perimeter and area instead of length.

1. I would like to v.extract to extract lines above a certain length -
ie weed out those short blips.

You need to use v.to.db.

1. use db.execute create a new table:

Example:
  echo "CREATE TABLE roadlength (cat integer, linelength double)" | db.execute

  Link this table as second table to your map:

  #check current settings:
  v.db.connect -p roads2

  #link new table:
  v.db.connect m=roads2 dr=dbf data='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf' \
               key=cat table=roadlength field=2

2. Verify that the new tables exists now:

  v.info -c roads2
  v.info -c roads2 field=2

Odd. Even tho field 2 is used to connect, v.info -c reports field 1 having the DB. v.info -c f=2 says database connection not defined. But the following steps work. Bug in v.info?

3. Generate new categories in the map:
  v.category roads2 out=roadsnew field=2 option=add
  v.category input=roadsnew option=report

  # should report something like this (for field=2):
  # type count min max
  # line 825 1 825
  # -> 825 lines in this map

Can't do this in-place?

2. I want to export the lines with line height as an attribute. Not
important now, but labelling lines with line height, using different
colors... (not ready to mess with NVIZ yet, but maybe that's the only
way?), or extracting certain line heights or ranges of heights.

... see above (now you should be able to do that).

where do I get the line height from? I didn't see it as an option for v.to.db.

-----
William Kyngesburye <kyngchaos@charter.net>
http://webpages.charter.net/kyngchaos/

All generalizations are dangerous, even this one.