Just found online script that with with some adjustments work with qgis 3.5.x
I lost the original post so cant credit the author.
What you do is:
- create fill layer change it to "geometry generator"
- change "geometry type" to points
- for the expression click the "sigma" button right to the textfield
- in the "expression dialog" window change tab to the "Function editor" and paste the code below there
- Now back to the "expression dialog" paste the function call like that: fillGrid(0.001,0.001,1) (first 2 values are the random size)
- Save changes and update view.
- Awesome random points are there.
Thanks to original author of the script.
from qgis.core import *
from qgis.gui import *
Define a grid based on the interval and the bounding box of
the feature. Grid will minimally cover the feature and be centre aligned
Create a multi-point geometry at the grid intersections where
the grid is enclosed by the feature - i.e. apply a clipping mask
Random value determines amount of randomness in X/Y within its
grid square a particular feature is allowed to have
def fillGrid(xInterval, yInterval, rand, feature, parent):
box = feature.geometry().boundingBox()
#Create a grid that minimally covers the boundary
#using the supplied intervals and centre it
countX = math.ceil(box.width() / xInterval)
countY = math.ceil(box.height() / yInterval)
#Align the grid
gridX = countX * xInterval
gridY = countY * yInterval
dX= gridX - box.width()
dY= gridY - box.height()
xMin = box.xMinimum() - (dX/2)
yMin = box.yMinimum() - (dY/2)
points = 
#+1 to draw a symbol on the n+1th grid element
for xOff in range(countX+1):
for yOff in range(countY+1):
ptX = xMin + xOff*(xInterval) + rand * random.uniform(0,xInterval)
ptY = yMin + yOff*(yInterval) + rand * random.uniform(0,xInterval)
pt = QgsPointXY(ptX,ptY)
point = QgsGeometry.fromPointXY(pt)