#1756: V.Distance Command Problem
------------------------------------------------------+---------------------
Reporter: scorpionlegend92 | Owner: grass-dev@…
Type: defect | Status: new
Priority: critical | Milestone: 6.4.3
Component: Default | Version: 6.4.2
Keywords: v.distance, attribute of nearest feature | Platform: MSWindows 7
Cpu: Unspecified |
------------------------------------------------------+---------------------
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.
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.
Replying to [comment:1 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.
Replying to [comment:2 mmetz]:
> Replying to [comment:1 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:
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.)
Replying to [comment:3 mlennert]:
> Replying to [comment:2 mmetz]:
> > Replying to [comment:1 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.
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.
Replying to [comment:5 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).
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.
Replying to [comment:8 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)
}}}