Bug #4761

Distance matrix: k becomes k-1 when working with one layer.

Added by Borys Jurgiel over 1 year ago. Updated 26 days ago.

Status:Reopened Start Date:01/07/2012
Priority:High Due date:
Assigned to:- % Done:

0%

Category:fTools
Target version:Version 2.0.0 Estimated time:0.50 hour
Platform: Patch supplied:Yes
Platform version: Affected version:master
Status info: Causes crash or corruption:No
Resolution:

Description

In order to replicate: use one layer (target point layer = input point layer), and k=2. Run any analysis.
It finds k=2 points: the input point itself and a second point. The first point is (correctly) dropped, so k becomes 1 instead of 2.

History

Updated by Borys Jurgiel over 1 year ago

  • Priority changed from Normal to 6
  • Estimated time set to 0.50

I set priority to Urgent, as it produces false results.

Updated by Borys Jurgiel over 1 year ago

  • Causes crash or corruption changed from No to Yes

Updated by Borys Jurgiel over 1 year ago

  • Subject changed from Distance matrix turns k into k-1 when working with one layer. to Distance matrix: k becomes k-1 when working with one layer.

Updated by Giovanni Manghi about 1 year ago

  • Priority changed from 6 to High

Updated by Paolo Cavallini about 1 year ago

  • Target version changed from Version 1.7.4 to Version 1.8.0

Updated by Giovanni Manghi 12 months ago

  • Assigned to deleted (cfarmer -)

Updated by Salvatore Larosa 12 months ago

  • Status changed from New to Feedback
  • Causes crash or corruption changed from Yes to No

for me works fine as well as QGIS doesn't crash!

Can you share your testcase?

Updated by Paolo Cavallini 9 months ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

Updated by Giovanni Manghi 8 months ago

  • Status changed from Feedback to Closed
  • Resolution set to worksforme

Closing for lack of feedback. Please reopen if necessary.

Updated by vinayan Parameswaran 26 days ago

This is a bug that has been there since Qgis 1.8. I can't share a shapefile now. In fact, it will not work for any file.

How to replicate:

  • Create a point layer with 4 point features.Populate Id field with unique values.
  • In distance matrix dialog, set input layer and target layer as the same layer.
  • set id field as input and output unique fields.
  • Output Matrix Type -> select Linear Matrix. Enable the checkbox 'use only nearest(k) points' and set its value to 1.
  • now ideally it should create a CSV file with four records because we chose a single neighbour only.
  • But the resulting CSV is blank
  • Now try increasing the nearest(k) value to 2.
  • now for each feature in the shapefile, there should be two rows in the csv. so there should be 8 rows. But you can see that there are only four rows.

I have submitted a pull request that addresses this issue here.
https://github.com/qgis/Quantum-GIS/pull/538

Updated by vinayan Parameswaran 26 days ago

  • Status changed from Closed to Reopened
  • Resolution deleted (worksforme)
  • Patch supplied changed from No to Yes

Also available in: Atom PDF