[GRASS-dev] Vlib: how to delete an object from a GRASS vector map

Dear all,

I am struggling to understand how to delete an object, including its
attached attributes, from a GRASS vector map.

I open the map with:

Vect_open_update ( &Map, MAPS[i].tempname, mapset );

Then I find the category IDs of the objects I want to delete and then I
do:

Vect_delete_line ( &Map, cat );
Vect_field_cat_del ( Cats, field, cat );

and Vect_close() after the work is done.

However, the next module I try to run on the modified map
throws an error:

ERROR: Attempt to read dead line [282]

How do I eliminate dead lines from the map?

Thanks,

Ben

--
Benjamin Ducke
Senior Applications Support and Development Officer

Oxford Archaeology Ltd
Janus House
Osney Mead
OX2 0ES
Oxford, U.K.

Tel: +44 (0)1865 263 800 (switchboard)
Tel: +44 (0)1865 980 758 (direct)
Fax :+44 (0)1865 793 496
benjamin.ducke@oxfordarch.co.uk

------
Files attached to this email may be in ISO 26300 format (OASIS Open Document Format). If you have difficulty opening them, please visit http://iso26300.info for more information.

On Thu, Aug 21, 2008 at 6:54 PM, Benjamin Ducke
<benjamin.ducke@oxfordarch.co.uk> wrote:

Dear all,

I am struggling to understand how to delete an object, including its
attached attributes, from a GRASS vector map.

I open the map with:

Vect_open_update ( &Map, MAPS[i].tempname, mapset );

Then I find the category IDs of the objects I want to delete and then I
do:

Vect_delete_line ( &Map, cat );
Vect_field_cat_del ( Cats, field, cat );

and Vect_close() after the work is done.

However, the next module I try to run on the modified map
throws an error:

ERROR: Attempt to read dead line [282]

How do I eliminate dead lines from the map?

In vector/v.digit/line.c I have found:

            /* delete lines with less than two points */
            Vect_delete_line(&Map, el->line);
            for (i = 0; i < el->Cats->n_cats; i++) {
                check_record(el->Cats->field[i], el->Cats->cat[i]);
            }

Might be something like this...

Markus

Hi,

2008/8/23 Markus Neteler <neteler@osgeo.org>:

On Thu, Aug 21, 2008 at 6:54 PM, Benjamin Ducke
<benjamin.ducke@oxfordarch.co.uk> wrote:

I am struggling to understand how to delete an object, including its
attached attributes, from a GRASS vector map.

I open the map with:

Vect_open_update ( &Map, MAPS[i].tempname, mapset );

Then I find the category IDs of the objects I want to delete and then I
do:

Vect_delete_line ( &Map, cat );
Vect_field_cat_del ( Cats, field, cat );

the second argument of Vect_delete_line() is feature id not category.
Feature ids start at 1. You get number of features by
Vect_get_num_lines().

Good luck, Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

2008/8/23 Martin Landa <landa.martin@gmail.com>:

On Thu, Aug 21, 2008 at 6:54 PM, Benjamin Ducke
<benjamin.ducke@oxfordarch.co.uk> wrote:

I am struggling to understand how to delete an object, including its
attached attributes, from a GRASS vector map.

I open the map with:

Vect_open_update ( &Map, MAPS[i].tempname, mapset );

Then I find the category IDs of the objects I want to delete and then I
do:

Vect_delete_line ( &Map, cat );
Vect_field_cat_del ( Cats, field, cat );

the second argument of Vect_delete_line() is feature id not category.
Feature ids start at 1. You get number of features by
Vect_get_num_lines().

I forgot to mention, to get list of feature ids which have given
field/category use

Vect_cidx_find_all(..., cat, list);

then

for (i = 0; i < list->n_values; i++) {
    Vect_delete_line(&Map, list->value[i];
}

Note that you need to open vector map at topology level (2) to use
Vect_cidx_find_all(..., cat, list) otherwise you need to read all
features and check their category manually.

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *