Vector attributes

David D Gray ddgray at
Mon Apr 3 09:00:34 EDT 2000

spijker at wrote:

> I'm creating a program that creates vector areas. When such an area is
> written to disk  with 'Vect_write_line(map,AREA,pnts)' I also want to give
> that area an attribute. The problem is that I don't know how to achieve
> this. Is there a function to create attributes or can I give the area
> attribute to vect_write_line? The Grass Programming Guide wasn't very
> clear on this (or I missed it ;-)
> Grtz, Job

I have been working on similar tasks recently with shapefile

I don't think there is a particular function for this. You must create a
dig_att file with G_fopen_new, or open an already existing with
G_fopen_append. Then a line like

fprintf( attribute_file, "L  %-12f  %-12f  %-8d \n",
         x_co_ordinate, y_co_ordinate, some_int_attribute );

writes the line. It will look something like

L  123456.876543  919828.477583  13

in an ascii file of the map's name under ${MAPSET}/dig_att 

The problem is - you must assign a label point to the polygon,
which must be on the interior of the polygon (but outside any 
islands the polygon might have). This is far from trivial
to work out in the general case. But depending on the way you
are building polygons you might the advantage of information that
allows you to assign a suitable point.

Hope this helps


More information about the grass-user mailing list