[GRASSLIST:2694] Re: extracting vector attributes

Christopher Fonnesbeck chris at fonnesbeck.org
Fri Feb 20 08:33:08 EST 2004


On Feb 20, 2004, at 3:31 AM, Radim Blazek wrote:

>>>> I am trying to determine the area of each polygon in a layer, and
>>>> store
>>>> this statistic as a column in the attribute table (my vector
>>>> attributes
>>>> are stored in MySQL). There appears to be no vector function in the
>>>> reference manual that provide this function, but I'm sure there must
>>>> be
>>>> something that does this. Please point me in the right direction.
>>>
>>> v.to.db option=area
>>>
>>> More precisely/generally, it does not update each row in the table by
>>> area size
>>> of each polygon, but by the sum of area sizes of all polygons with 
>>> the
>>> same category.
>>
>> OK, it sounds like I will have to program something. I need the area 
>> of
>> each polygon as an attribute field, since I am trying to classify
>> stream segments by the size of the sub-basin that drains into it. The
>> easiest thing, I suppose would be to take both coverages over to
>> ArcView, since this is a trivial operation there (but that would be
>> cheating, I guess ;-] )
>
> Why? What is the problem? Why you cannot use v.to.db?
> If you don't have unique category for each polygon you can add it
> by v.category.

Well, my vector layer of polygons comes from a raster layer, via 
r.to.vect, which creates a mysql table with cat and value columns, and 
an empty label column. Then, running:

v.to.db map=basins type=boundary option=area units=h

gives me a dbmi protocol error. Is this because the table already 
exists? I am assuming this means I have to write some C code to get the 
areas, create a database column, and load the values.

C.

--
Christopher J. Fonnesbeck ( c h r i s @ f o n n e s b e c k . o r g )
Georgia Cooperative Fish & Wildlife Research Unit, University of Georgia




More information about the grass-user mailing list