Bug #5710

fTools Random points cannot create 0 points within a polygon

Added by Kenton Ngo about 1 year ago. Updated 2 months ago.

Status:New Start Date:06/01/2012
Priority:Normal Due date:
Assigned to:- % Done:

0%

Category:-
Target version:Version 2.0.0
Platform:Mac OS X Patch supplied:No
Platform version: Affected version:master
Status info: Causes crash or corruption:No
Resolution:

Description

When using fTools Random Points to generate a specified number of points per polygon using an input field, it crashes if I direct it to assign 0 points to any polygon.

I have to reformat my data to create at least one dot per polygon and then manually remove the extra points later if they are supposed to accurately show 0.

For example, if I want to run a dot density map that has one dot per 25 people, and one of the polygons is a lake that has 0 people in it, I still have to assign 1 dot to it or else it will crash. This would be inaccurate, so I have to manually remove it later.

Appears to be a common issue, see http://gis.stackexchange.com/questions/16830/dot-density-maps-in-qgis

Error text below:

An error has occured while executing Python code:

Traceback (most recent call last):
File "/Users/kentonngo/.qgis/python/plugins/fTools/tools/doRandPoints.py", line 121, in accept
self.randomize(inLayer, outPath, minimum, design, value)
File "/Users/kentonngo/.qgis/python/plugins/fTools/tools/doRandPoints.py", line 211, in randomize
else: points = self.loopThruPolygons(inLayer, value, design)
File "/Users/kentonngo/.qgis/python/plugins/fTools/tools/doRandPoints.py", line 258, in loopThruPolygons
sPoints.extend(self.simpleRandom(value, sGeom, sExt.xMinimum(), sExt.xMaximum(), sExt.yMinimum(), sExt.yMaximum()))
File "/Users/kentonngo/.qgis/python/plugins/fTools/tools/doRandPoints.py", line 166, in simpleRandom
add = ( 70.00 - 40.00 ) / n
ZeroDivisionError: float division

Python version:
2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)]

QGIS version:
1.9.90-Alpha Alpha, e13e45f

Python path: ['/Users/kentonngo/.qgis/python/plugins/sextante', '/Applications/QGIS-1.9.app/Contents/MacOS/../Resources/python', '/Users/kentonngo/.qgis/python', '/Users/kentonngo/.qgis/python/plugins', '/Applications/QGIS-1.9.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/3/Python/2.6', '/Library/Frameworks/GDAL.framework/Versions/1.9/Python/2.6/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Python/2.6/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode', '/Users/kentonngo/.qgis/python/plugins/fTools/tools', '/Users/kentonngo/.qgis/python/plugins/mmqgis/forms', '/Users/kentonngo/Desktop']

Screen_Shot_2013-04-13_at_11.57.49_AM.png (660.7 kB) maning sambale, 04/12/2013 09:00 pm

History

Updated by Paolo Cavallini 10 months ago

  • Target version set to Version 2.0.0

Updated by maning sambale 2 months ago

I cannot reproduce this issue. See attached screenshot.

The input polygon is a hex grid with attribute value range of 0-8 (0 is colored as red). Using the Vector > Research Tools > Random points, and using the Use value input field to set the number of points on each polygon, the process is completed and the resulting point layer looks OK. No point data is created if the polygon attribute value is 0.

System: Ubuntu precise latest nightly build.

Proposed for closing this bug.

Also available in: Atom PDF