Bug report #5181

fTools python error with option k=1 on 'Distance Matrix'

Added by David Quinn over 12 years ago. Updated over 7 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Processing/QGIS
Affected QGIS version:master Regression?:
Operating System: Easy fix?:
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:14924

Description

When using the fTools plugin, 'Vector -> Analysis Tools -> Distance Matrix', if 'Summary Distance Matrix' is chosen with 'Use only the nearest (k) target points' and the value of '1' is chosen, the plugin crashes. I attached a file with a minor modification of how to fix the function def linearMatrix(), but I'm not sure how to connect to the code repository, or if it follows the correct conventions.

Here is the error message:

An error has occured while executing Python code:

Traceback (most recent call last):
File "C:\\PROGRA~2\\Quantum GIS Wroclaw\\apps\\qgis\\python\\plugins\\fTools\\tools\\doPointDistance.py", line 140, in accept
self.compute(point1, point2, field1, field2, outPath, matType, nearest, self.progressBar)
File "C:\\PROGRA~2\\Quantum GIS Wroclaw\\apps\\qgis\\python\\plugins\\fTools\\tools\\doPointDistance.py", line 186, in compute
self.linearMatrix(writer, provider1, provider2, index1, index2, nearest, distArea, matType, sindex, progressBar)
File "C:\\PROGRA~2\\Quantum GIS Wroclaw\\apps\\qgis\\python\\plugins\\fTools\\tools\\doPointDistance.py", line 243, in linearMatrix
mean = sum(distList) / len(distList)
ZeroDivisionError: integer division or modulo by zero

Python version:
2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]

QGIS version:
1.7.4-Wroclaw Wroclaw, 411aff6

Python path: ['C:/PROGRA~2/Quantum GIS Wroclaw/apps/qgis/./python', 'C:/Users/djq/.qgis/python', 'C:/Users/djq/.qgis/python/plugins', 'C:/PROGRA~2/Quantum GIS Wroclaw/apps/qgis/./python/plugins', 'C:\\\\Program Files (x86)\\\\ArcGIS\\\\Desktop10.0\\\\Bin', 'c:\\\\mapnik-2.0.1rc0\\\\python\\\\2.7\\\\site-packages', 'D:\\\\Dropbox\\\\CODE\\\\Python', 'D:\\\\Dropbox\\\\CODE\\\\Python\\\\web_mapping', 'C:\\\\Program Files (x86)\\\\Quantum GIS Wroclaw', 'C:\\\\Windows\\\\system32\\\\python27.zip', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\DLLs', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\lib', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\lib\\\\plat-win', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\lib\\\\lib-tk', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\qgis\\\\bin', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\lib\\\\site-packages', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\PIL', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32\\\\lib', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Pythonwin', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\wx-2.8-msw-unicode', 'C:\\\\Users\\\\djq\\\\.qgis\\\\python\\\\plugins\\\\mmqgis/forms', 'C:\\\\PROGRA~2\\\\Quantum GIS Wroclaw\\\\apps\\\\qgis\\\\python\\\\plugins\\\\fTools\\\\tools']

patch.py Magnifier (1.71 KB) David Quinn, 2012-03-14 02:43 PM

Associated revisions

Revision 580b9474
Added by Borys Jurgiel about 11 years ago

Merge pull request #769 from vinayan/topol

Fix #5181,#4761 - Ftools-Distance Matrix

History

#1 Updated by Alexander Bruy over 12 years ago

  • Category set to 44

#2 Updated by Giovanni Manghi over 12 years ago

  • Target version changed from 35 to Version 1.8.0

#3 Updated by Paolo Cavallini about 12 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#4 Updated by Giovanni Manghi over 11 years ago

  • OS version deleted (Windows 7)
  • Priority changed from Low to High

Still true on the latest master

#5 Updated by Giovanni Manghi over 11 years ago

  • Subject changed from fTools error with option k=1 on 'Distance Matrix' to fTools python error with option k=1 on 'Distance Matrix'

#6 Updated by Daniel Vaz over 11 years ago

Please give it a try https://github.com/qgis/Quantum-GIS/pull/734

Thanks in advance

#7 Updated by vinayan Parameswaran about 11 years ago

below pull request should fix it..
https://github.com/qgis/Quantum-GIS/pull/769

#8 Updated by Borys Jurgiel about 11 years ago

  • Status changed from Open to Closed

#9 Updated by Giovanni Manghi over 7 years ago

The "ftools" category is being removed from the tracker, changing the category of this ticket to "Processing/QGIS" to not leave the category orphaned.

Also available in: Atom PDF