Bug report #5710
fTools Random points cannot create 0 points within a polygon
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Processing/QGIS | ||
Affected QGIS version: | master | Regression?: | |
Operating System: | Mac OS X | Easy fix?: | |
Pull Request or Patch supplied: | No | Resolution: | worksforme |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 15234 |
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']
History
#1 Updated by Paolo Cavallini about 12 years ago
- Target version set to Version 2.0.0
#2 Updated by maning sambale over 11 years ago
- File Screen_Shot_2013-04-13_at_11.57.49_AM.png added
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.
#3 Updated by Paolo Cavallini over 11 years ago
- Category set to 44
#4 Updated by Giovanni Manghi over 11 years ago
- Resolution set to worksforme
- Status changed from Open to Closed
Works fine in master, reopen if necessary.
#5 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.