[GRASS-dev] v.select features without category skipped

Hi devs,

this morning I got a problem with v.select, I don't understand if is a
bug or what... I repeated the procedure with north carolina dataset

g.region vect=zipcodes -ap

v.mkgrid map=zipcodes_grid box=10000,10000

v.category zipcodes_grid opt=report
Layer/table: 1/zipcodes_grid
type count min max
point 0 0 0
line 0 0 0
boundary 0 0 0
centroid 42 1 42
area 0 0 0
face 0 0 0
kernel 0 0 0
all 42 1 42

v.select ain=zipcodes_grid bin=zipcodes operator=touches
out=zipcodes_grid_final --o
WARNING: Vector map <zipcodes_grid_final> already exists and will be
         overwritten
Processing features...
100%
Processing areas...
100%
Writing selected features...
100%
Writing attributes...
WARNING: Array of values to select from column <cat> is empty
WARNING: Unable to copy table for layer 1
DBMI-SQLite driver error:
Unable to create index:
create unique index if not exists zipcodes_grid_final_cat on
zipcodes_grid_final ( cat )
no such table: main.zipcodes_grid_final

DBMI-SQLite driver error:
Unable to create index:
create unique index if not exists zipcodes_grid_final_cat on
zipcodes_grid_final ( cat )
no such table: main.zipcodes_grid_final

WARNING: Unable to create index
WARNING: 97 features from <zipcodes_grid@user1> without category skipped
Building topology for vector map <zipcodes_grid_final@user1>...
Registering primitives...
0 primitives registered
0 vertices registered
Building areas...
100%
0 areas built
0 isles built
Attaching islands...
Attaching centroids...
Number of nodes: 0
Number of primitives: 0
Number of points: 0
Number of lines: 0
Number of boundaries: 0
Number of centroids: 0
Number of areas: 0
Number of isles: 0
v.select complete. 0 features written to output.

is someone able to reproduce the error? if yes I will open a ticket (I
tested both grass70 and grass72, I didn't with trunk)

--
ciao
Luca

www.lucadelu.org

Luca Delucchi wrote

Hi devs,

this morning I got a problem with v.select, I don't understand if is a
bug or what... I repeated the procedure with north carolina dataset

g.region vect=zipcodes -ap

v.mkgrid map=zipcodes_grid box=10000,10000

v.category zipcodes_grid opt=report
Layer/table: 1/zipcodes_grid
type count min max
point 0 0 0
line 0 0 0
boundary 0 0 0
centroid 42 1 42
area 0 0 0
face 0 0 0
kernel 0 0 0
all 42 1 42

v.select ain=zipcodes_grid bin=zipcodes operator=touches
out=zipcodes_grid_final --o
WARNING: Vector map
<zipcodes_grid_final>
already exists and will be
         overwritten
Processing features...
100%
Processing areas...
100%
Writing selected features...
100%
Writing attributes...
WARNING: Array of values to select from column
<cat>
is empty
WARNING: Unable to copy table for layer 1
DBMI-SQLite driver error:
Unable to create index:
create unique index if not exists zipcodes_grid_final_cat on
zipcodes_grid_final ( cat )
no such table: main.zipcodes_grid_final

DBMI-SQLite driver error:
Unable to create index:
create unique index if not exists zipcodes_grid_final_cat on
zipcodes_grid_final ( cat )
no such table: main.zipcodes_grid_final

WARNING: Unable to create index
WARNING: 97 features from &lt;zipcodes_grid@user1&gt; without category
skipped
Building topology for vector map &lt;zipcodes_grid_final@user1&gt;...
Registering primitives...
0 primitives registered
0 vertices registered
Building areas...
100%
0 areas built
0 isles built
Attaching islands...
Attaching centroids...
Number of nodes: 0
Number of primitives: 0
Number of points: 0
Number of lines: 0
Number of boundaries: 0
Number of centroids: 0
Number of areas: 0
Number of isles: 0
v.select complete. 0 features written to output.

is someone able to reproduce the error? if yes I will open a ticket (I
tested both grass70 and grass72, I didn't with trunk)

tested with

System Info
GRASS version: 7.3.svn
GRASS SVN revision: r69838
Build date: 2016-11-17
Build platform: x86_64-w64-mingw32
GDAL: 2.1.2
PROJ.4: 4.9.3
GEOS: 3.5.0
SQLite: 3.14.1
Python: 2.7.5
wxPython: 2.8.12.1
Platform: Windows-8-6.2.9200 (OSGeo4W)

v.select ainput=zipcodes_grid@user1 binput=zipcodes_wake@PERMANENT
output=zipcodes_grid_final operator=touches
Processing features...
Processing areas...
Writing selected features...
Writing attributes...
WARNING: Array of values to select from column <cat> is empty
WARNING: Unable to copy table for layer 1
WARNING: Unable to create index
WARNING: 97 features from <zipcodes_grid@user1> without category skipped
Building topology for vector map <zipcodes_grid_final@user1>...
Registering primitives...
0 primitives registered
0 vertices registered
Building areas...
0 areas built
0 isles built
Attaching islands...
Attaching centroids...
Number of nodes: 0
Number of primitives: 0
Number of points: 0
Number of lines: 0
Number of boundaries: 0
Number of centroids: 0
Number of areas: 0
Number of isles: 0
v.select complete. 0 features written to output.

same here

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/v-select-features-without-category-skipped-tp5296258p5296263.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

On 17/11/16 14:11, Luca Delucchi wrote:

Hi devs,

this morning I got a problem with v.select, I don't understand if is a
bug or what... I repeated the procedure with north carolina dataset

g.region vect=zipcodes -ap

v.mkgrid map=zipcodes_grid box=10000,10000

v.category zipcodes_grid opt=report
Layer/table: 1/zipcodes_grid
type count min max
point 0 0 0
line 0 0 0
boundary 0 0 0
centroid 42 1 42
area 0 0 0
face 0 0 0
kernel 0 0 0
all 42 1 42

v.select ain=zipcodes_grid bin=zipcodes operator=touches
out=zipcodes_grid_final --o
WARNING: Vector map <zipcodes_grid_final> already exists and will be
         overwritten
Processing features...
100%
Processing areas...
100%
Writing selected features...
100%
Writing attributes...
WARNING: Array of values to select from column <cat> is empty

i.e. no features found which is logical, as there are no zipcode areas that touch a grid area. 'touches' is normally defined as [1]

"a touches b: they have at least one boundary point in common, but no interior points."

Try with intersects, overlaps, etc.

I agree though that the error message is very unclear. After the "Array of values ... is empty" it should just stop. After a very rapid look at main.c of v.select it seems to me that it doesn't check the result of the selection and just goes on trying to write a new file...

Moritz

[1] https://en.wikipedia.org/wiki/DE-9IM

On 17/11/16 18:06, Moritz Lennert wrote:

On 17/11/16 14:11, Luca Delucchi wrote:

Hi devs,

this morning I got a problem with v.select, I don't understand if is a
bug or what... I repeated the procedure with north carolina dataset

g.region vect=zipcodes -ap

v.mkgrid map=zipcodes_grid box=10000,10000

v.category zipcodes_grid opt=report
Layer/table: 1/zipcodes_grid
type count min max
point 0 0 0
line 0 0 0
boundary 0 0 0
centroid 42 1 42
area 0 0 0
face 0 0 0
kernel 0 0 0
all 42 1 42

v.select ain=zipcodes_grid bin=zipcodes operator=touches
out=zipcodes_grid_final --o
WARNING: Vector map <zipcodes_grid_final> already exists and will be
         overwritten
Processing features...
100%
Processing areas...
100%
Writing selected features...
100%
Writing attributes...
WARNING: Array of values to select from column <cat> is empty

i.e. no features found which is logical, as there are no zipcode areas
that touch a grid area. 'touches' is normally defined as [1]

"a touches b: they have at least one boundary point in common, but no
interior points."

Try with intersects, overlaps, etc.

I agree though that the error message is very unclear. After the "Array
of values ... is empty" it should just stop. After a very rapid look at
main.c of v.select it seems to me that it doesn't check the result of
the selection and just goes on trying to write a new file...

Try the attached patch. Not very elegant and not well tested, but seems to work for me.

Moritz

(attachments)

v_select_no_features.diff (3.75 KB)

On 17 November 2016 at 18:06, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

i.e. no features found which is logical, as there are no zipcode areas that
touch a grid area. 'touches' is normally defined as [1]

"a touches b: they have at least one boundary point in common, but no
interior points."

Try with intersects, overlaps, etc.

yes with intersects it work as expected...

Moritz

--
ciao
Luca

www.lucadelu.org

On 17 November 2016 at 18:38, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

Try the attached patch. Not very elegant and not well tested, but seems to
work for me.

It work also for me (I tested in trunk) and I like it

Moritz

--
ciao
Luca

www.lucadelu.org

On 20/12/16 16:03, Luca Delucchi wrote:

On 17 November 2016 at 18:38, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

Try the attached patch. Not very elegant and not well tested, but seems to
work for me.

It work also for me (I tested in trunk) and I like it

You can go ahead and commit to trunk, unless someone objects. At least this way it gets some testing.

Moritz

On 20 December 2016 at 16:08, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

You can go ahead and commit to trunk, unless someone objects. At least this
way it gets some testing.

are you sure? you should submit it :-/

Moritz

--
ciao
Luca

www.lucadelu.org

On 20/12/16 16:18, Luca Delucchi wrote:

On 20 December 2016 at 16:08, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

You can go ahead and commit to trunk, unless someone objects. At least this
way it gets some testing.

are you sure? you should submit it :-/

I had hoped to put the work on you... :wink:

But it's done: r70103.

But we should keep this in mind and observe whether this does not cause any issues. Maybe open a ticket ?

Moritz

On Tue, Dec 20, 2016 at 10:36 AM, Moritz Lennert <
mlennert@club.worldonline.be> wrote:

On 20/12/16 16:18, Luca Delucchi wrote:

On 20 December 2016 at 16:08, Moritz Lennert
<mlennert@club.worldonline.be> wrote:

You can go ahead and commit to trunk, unless someone objects. At least
this
way it gets some testing.

are you sure? you should submit it :-/

I had hoped to put the work on you... :wink:

But it's done: r70103.

But we should keep this in mind and observe whether this does not cause
any issues. Maybe open a ticket ?

Isn't an empty vector map an expected result in this case? What happens
when you do this in GUI (where output is added automatically to Map
Display)? Ticket might be appropriate.

On 20/12/16 17:14, Vaclav Petras wrote:

On Tue, Dec 20, 2016 at 10:36 AM, Moritz Lennert
<mlennert@club.worldonline.be <mailto:mlennert@club.worldonline.be>> wrote:

    On 20/12/16 16:18, Luca Delucchi wrote:

        On 20 December 2016 at 16:08, Moritz Lennert
        <mlennert@club.worldonline.be
        <mailto:mlennert@club.worldonline.be>> wrote:

            You can go ahead and commit to trunk, unless someone
            objects. At least this
            way it gets some testing.

        are you sure? you should submit it :-/

    I had hoped to put the work on you... :wink:

    But it's done: r70103.

    But we should keep this in mind and observe whether this does not
    cause any issues. Maybe open a ticket ?

Isn't an empty vector map an expected result in this case? What happens
when you do this in GUI (where output is added automatically to Map
Display)? Ticket might be appropriate.

https://trac.osgeo.org/grass/ticket/3226