Opened 12 years ago

Closed 11 years ago

#1756 closed defect (fixed)

V.Distance Command Problem

Reported by: scorpionlegend92 Owned by: grass-dev@…
Priority: normal Milestone: 6.4.3
Component: Vector Version: 6.4.2
Keywords: v.distance, attribute of nearest feature Cc:
CPU: Unspecified Platform: MSWindows 7

Description

In v.distance, if I select "attribute of nearest feature given by to_column option" command and insert column name of nearest feature in "to" menu, v.distance command does not work.

Column name that I use is "name" that is present in the attribute table. I uploaded the data in grass from .shp file for which it created a .dbf also at back-end in the GIS database software folder in my documents.

Following error appears:

v.distance -a --overwrite from=PERN86@PERMANENT to=PERN86@PERMANENT to_type=point,line output=same4 upload=cat,dist,to_attr column=to_cat, loc_dist,name to_column=name table=same4 DBMI-DBF driver error: Column 'loc_dist' already exists (duplicate name) Cannot create table. Error in db_execute_immediate() ERROR: Unable to create table: 'create table same4 (from_cat integer, to_cat integer, loc_dist double precision, loc_dist double precision )' (Fri Oct 05 11:00:45 2012) Command finished (2 sec)

If I select only "category of the nearest feature", and "minimum distance to nearest feature", then v.distance command work properly and create a .dbf file that contain the desired distance information. In such case, following output appears without any error.

v.distance -a --overwrite from=PERN86@PERMANENT to=PERN86@PERMANENT to_type=point output=same5 upload=cat,dist column=to_cat, loc_dist to_column=name table=same5 1792 categories with more than 1 feature in vector map <PERN86@PERMANENT> 7225 distances calculated 7225 records inserted Building topology for vector map <same5>... Registering primitives... 7225 primitives registered 14450 vertices registered Building areas... 0 areas built 0 isles built Attaching islands... Attaching centroids... Number of nodes: 84 Number of primitives: 7225 Number of points: 0 Number of lines: 7225 Number of boundaries: 0 Number of centroids: 0 Number of areas: 0 Number of isles: 0 v.distance complete. (Fri Oct 05 11:01:18 2012) Command finished (2 sec)

Please check and resolve why does this command create error and does not work when I select attribute in upload, string.

Change History (10)

in reply to:  description ; comment:1 by mlennert, 12 years ago

Resolution: duplicate
Status: newclosed

If I'm not mistaken, this is a duplicate of #672.

It is fixed in grass7 since almost 2 months, but the fix has not yet been backported to the grass6 line.

MarkusM, any reason it shouldn't be backported ?

Closing this bug as a duplicate.

Moritz

in reply to:  1 ; comment:2 by mmetz, 12 years ago

Priority: criticalnormal

Replying to mlennert:

If I'm not mistaken, this is a duplicate of #672.

I think this is a different issue. Here, the table given with the table option already exists, but the module wants to create a new table. This is why the module fails.

In this case, overwriting the table (delete, then create anew) would be dangerous because the original table can be attached to an existing vector, resulting in loss of attributes for that vector.

Therefore I would rather check the table option for v.distance -a earlier and print a more useful message, asking the user to use a table name that does not yet exist. Decreasing priority.

Markus M

in reply to:  2 ; comment:3 by mlennert, 12 years ago

Replying to mmetz:

Replying to mlennert:

If I'm not mistaken, this is a duplicate of #672.

I think this is a different issue. Here, the table given with the table option already exists, but the module wants to create a new table. This is why the module fails.

Where do you see a table that already exists ? The table to be created is same4. The module complains about a column 'loc_dist' that already exists which comes from the create table statement where the creation of that column is asked for twice:

'create table same4 (from_cat integer, to_cat integer, loc_dist double precision, loc_dist double precision )'

And the problem goes away when the OP tries again (creating table same5), but without using to_attr in upload. This looks exactly like #672 to me (I didn't put the error message in #672, but it's exactly the same as you can see if you try with grass6.)

Moritz

in reply to:  3 comment:4 by mmetz, 12 years ago

Replying to mlennert:

Replying to mmetz:

Replying to mlennert:

If I'm not mistaken, this is a duplicate of #672.

I think this is a different issue. Here, the table given with the table option already exists, but the module wants to create a new table. This is why the module fails.

Where do you see a table that already exists ? The table to be created is same4. The module complains about a column 'loc_dist' that already exists which comes from the create table statement where the creation of that column is asked for twice:

'create table same4 (from_cat integer, to_cat integer, loc_dist double precision, loc_dist double precision )'

Right, I mixed up different bugs, sorry for the confusion! I have applied your patch from #672 to devbr6 and relbr64 in r53318/9.

Markus M

comment:5 by scorpionlegend92, 12 years ago

Is this problem resolved??

This command created problem when I selected this option: "attribute of nearest feature given by to_column option"

In this case, it does not execute the command and displays the above mentioned error. I have tried using different names for the columns of distance output file, but the same problem persist irrespective of the column name.

When we run v.distance command, it creates a dbf file that contains column name that we define in the command menu. The problem refers to creation of dbf file with these column names.

in reply to:  5 comment:6 by mlennert, 12 years ago

Replying to scorpionlegend92:

Is this problem resolved??

Yes. As mentioned, it is a duplicate of #672, which was fixed in svn. It is not fixed for version 6.4.2, but for all development versions (and thus will be fixed in 6.4.3).

Moritz

comment:7 by scorpionlegend92, 12 years ago

Resolution: duplicate
Status: closedreopened

This problem is still appearing in 6.4.3svn version. Following error appears:

v.distance -a --overwrite from=PERN@PERMANENT to=AKDNCombine@PERMANENT to_type=point,line output=distancecheck9 upload=cat,dist,to_attr column=cat,ping11,name to_column=name table=dist9 DBMI-DBF driver error: Column 'ping11' already exists (duplicate name) Cannot create table. Error in db_execute_immediate() ERROR: Unable to create table: 'create table dist9 (from_cat integer, cat integer, ping11 double precision, ping11 double precision )' (Tue Oct 09 12:58:25 2012) Command finished (12 sec)

Please check and confirm. If I un-check the attribute option from the menu, this command is working properly, but not by selecting the command. It fails to accept column name that will store distance information.

in reply to:  7 ; comment:8 by mlennert, 12 years ago

Replying to scorpionlegend92:

This problem is still appearing in 6.4.3svn version.

Did you do a fresh checkout and recompile of v.distance ? This was fixed 4 days ago.

Following error appears:

v.distance -a --overwrite from=PERN@PERMANENT to=AKDNCombine@PERMANENT to_type=point,line output=distancecheck9 upload=cat,dist,to_attr column=cat,ping11,name to_column=name table=dist9 DBMI-DBF driver error: Column 'ping11' already exists (duplicate name) Cannot create table. Error in db_execute_immediate() ERROR: Unable to create table: 'create table dist9 (from_cat integer, cat integer, ping11 double precision, ping11 double precision )' (Tue Oct 09 12:58:25 2012) Command finished (12 sec)

Please check and confirm.

I can't reproduce this. Using the NC demo data:

g.copy vect=hospitals,myhosp v.distance from=myhosp to=myhosp upload=cat,dist,to_attr to_column=CANCER column=to_cat,dist,to_cancer table=my_test_table -a

works as expected both with dbf and sqlite backend, creating the table my_test_table with the three columns.

Can you try to reproduce with the NC data ?

If you have the very latest 6.4.3svn version installed, maybe this could be a specific windows issue ?

Moritz

in reply to:  8 comment:9 by hellik, 12 years ago

Replying to mlennert:

Please check and confirm.

I can't reproduce this. Using the NC demo data:

g.copy vect=hospitals,myhosp v.distance from=myhosp to=myhosp upload=cat,dist,to_attr to_column=CANCER column=to_cat,dist,to_cancer table=my_test_table -a

works as expected both with dbf and sqlite backend, creating the table my_test_table with the three columns.

Can you try to reproduce with the NC data ?

If you have the very latest 6.4.3svn version installed, maybe this could be a specific windows issue ?

tested here with osgeo4w-grass64-dev-6.4.3svn-r53339 and example above

v.distance from=myhosp to=myhosp upload=cat,dist,to_attr to_column=CANCER column=to_cat,dist,to_cancer table=my_test_table -a
1716 Kategorien mit mehr als einem Feature in der Vektorkarte <myhosp>.
25600 Entfernungen berechnet.
25600 Einträge eingefügt.
v.distance komplett.
(Tue Oct 09 11:54:48 2012) Command finished (1 sec)                             

Helmut

comment:10 by hamish, 11 years ago

Component: DefaultVector
Resolution: fixed
Status: reopenedclosed

as per comment:6 and 8, should be fixed now.

reopen if needed.

Note: See TracTickets for help on using tickets.