I'm trying to generate random points at a specific density within a polygon layer. The polygon layer has 1850 features and I'm looking to have random points within each feature at 1/meter. Going through Vector -> Research tool -> Random points -> "Use this density of points" = 1 (assuming the default is based on unit of the project) -> Save As: .shp -> click OK. The OK button darkens, then lightens to normal without producing any result.
I've also tried going through the Processing Toolbox -> QGIS geoalgo -> Vect Creation Tools -> Random points inside polygons (fixed), set density = 1, and get error:
"Algorithm Random points inside polygons (fixed) starting...
float division by zero See log for more details"
Any ideas? I think it has something to do with the density parameter, but I haven't found what the unit used for the density is. Insight welcomed.
QGIS 2.14.3-Essen
-
Does this work: gis.stackexchange.com/questions/16830/dot-density-maps-in-qgisInactivated Account– Inactivated Account2016年07月07日 00:14:56 +00:00Commented Jul 7, 2016 at 0:14
-
Nah. The answer to that post contains an image of the tool I tried through Research Tools. Doesn't even think about running a process. And I am trying to make new points that are contained within polygons; not use information from existing attributes. But thanks!Scolopax– Scolopax2016年07月07日 00:57:11 +00:00Commented Jul 7, 2016 at 0:57
-
Gotcha! Hmmm....Inactivated Account– Inactivated Account2016年07月07日 01:08:42 +00:00Commented Jul 7, 2016 at 1:08
-
Is your polygon layer valid? A division by zero can occur when there is invalid geometries.romainbh– romainbh2016年07月07日 09:08:39 +00:00Commented Jul 7, 2016 at 9:08
1 Answer 1
I've had a similar problem and I think it's due to the way that QGIS calculates the number of points when using density. It is rounding the density * polygon area for each polygon. So if that value is < 0.5 for any of your polygons, QGIS will round this to 0 and then you'll get a divide by 0 error.
For example:
Say you choose a density of 0.01. If you have a polygon with an area of 49, then 49 * 0.01 = 0.49. QGIS will then round this down to 0.
The solution for me was to remove the polygons that were smaller than this, then re-add them afterwards.