[GRASS-user] Determining maximum value of attributes where areas are overlapping in imported vector layer

Moritz Lennert mlennert at club.worldonline.be
Tue Jul 8 10:21:30 EDT 2008


On 08/07/08 15:33, Rainer M Krug wrote:
> On Tue, Jul 8, 2008 at 3:19 PM, Moritz Lennert
> <mlennert at club.worldonline.be> wrote:
>> On 08/07/08 15:02, Rainer M Krug wrote:
>>> On Tue, Jul 8, 2008 at 10:25 AM, Rainer M Krug <r.m.krug at gmail.com> wrote:
>>>> On Mon, Jul 7, 2008 at 9:37 PM, Markus Neteler <neteler at osgeo.org> wrote:
>>>>> On Mon, Jul 7, 2008 at 6:28 PM, Rainer M Krug <r.m.krug at gmail.com>
>>>>> wrote:
>>>>>> On Mon, Jul 7, 2008 at 6:19 PM, Markus Neteler <neteler at osgeo.org>
>>>>>> wrote:
>>>>>>> On Mon, Jul 7, 2008 at 6:11 PM, Rainer M Krug <r.m.krug at gmail.com>
>>>>>>> wrote:
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> I am back with a problem of imported shape files:
>>>>>>>>
>>>>>>>> I have imported a shape file and it contains several areas where
>>>>>>>> polygons are overlapping. After I managed to obtain the number of
>>>>>>>> overlapping polygons and exported it to a raster layer
>>>>>>>> (http://grass.osgeo.org/wiki/Vector_Overlapping_Areas), I would now
>>>>>>>> need the maximum value of an attribute column for this areas.
>>>>>>>>
>>>>>>>> Any ideas how I can achieve this?
>>>>>>> You can use 'db.select':
>>>>>>>
>>>>>>> echo "SELECT max(N1) FROM lidar2" | db.select
>>>>>>> max(N1)
>>>>>>> 512834.76000000000931
>>>>>> Sorry for not being spoecific enough - I want the maximum values as
>>>>>> ributes in an attribute table.
>>>>>> As far as I can see, this just gives me the maximum value of the whole
>>>>>> table - but I need it spatially, i.e. for each area which is
>>>>>> overlapping, the maximum value.
>>>>> Then v.to.db might be helpful.
>>>>> http://grass.osgeo.org/grass64/manuals/html64_user/v.to.db.html
>>>>>
>>>>> -> see qcolumn parameter.
>>>> Thanks - tha is working now.
>>> I was to fast - it is not working.
>>>
>>> The reason is the following: if a small polygon A with YEAR=2006 is
>>> completely overlapping with a larger polygon B with YEAR=2000,
>>> max(YEAR) returns 2006 for the whole of polygon B - which is not what
>>> I want. I would like to have 2006 for polygon A and 200 for polygon B,
>>> except of the are where it overlaps with polygon A.
>>>
>>> Any ideas on how to achieve this?
>> v.overlay + v.to.db ?
> 
> I thought the same, but when I do v.overlay, it only takes one value
> per polygon over to the new layer. If I could specify the max(YEAR)
> query to choose the value, that would be the solution. Just look at
> http://grass.osgeo.org/wiki/Vector_Overlapping_Areas - I used the
> second solution for the count of the layers per location - but I don;t
> have an ide to do it for max(YEAR)

Not sure I understand. v.overlay operator=or should create new entities 
which are (to use your example): a piece of polygon A where there is 
only polygon A, a piece of polygon B where there is only polygon B and 
the common area between the two. In the table, you should then have the 
columns of both (a_cat, b_cat and a_YEAR, b_YEAR, etc) some of which 
will be null where you only have one of the two polygons. You can then 
query this table with something like this:

select a_YEAR ... where b_YEAR is null  or a_YEAR<b_YEAR

Moritz


More information about the grass-user mailing list