[GIS] Creating random points using density-QGIS

point-in-polygonqgisrandom

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

Best Answer

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.

Related Question