I'm looking for a way to fill polygon(s) in QGIS with randomly rotated symbols, to reproduce this effect:
This was generated with Illustrator, and as such it is actually a periodic pattern, reproduced many times, but the wavelenght is large enough compared to the polygons and you do not notice unless you pay attention.
I tried to reproduce this effect with QGIS. My approach was to use a point pattern fill, with a short line segment as the base symbol and appropriate offset, and each line being rotated by a random amount — this is controlled by an expression, rand(-180,180)
(notice the yellow expression next to "rotation").
Although the preview looks reasonable, the final rendered effect is not:
Here, we see that the pattern is built of rather small tiles (the size of the preview, more or less, i.e. approx. the distance between two symbols in this case). We see the tiles repeating themselves way too quiclky for aesthetics, and we also notive that some symbols happen to be truncated on tiles edges — QGIS is apparently blissfuly ignorant of this fact, and we end up with "wedges" corresponding to corners of the pattern.
And so, I would suggest that a possibility to solve my problem is to force QGIS to calculate a larger tile. But how? More generally, how to generate a random (or pseudo-random) pattern?
Best Answer
You can create pattern fill using different approach, as follows:
Create a new point grid shapefile using the tool
Vector -> Research tools -> Regular points
. 2. Select an input polygon file to get the extent, define grid spacing (1m in this example), and give name to output file.
rand( -180,180)
in the expression beside the Angle, and 'Overlay' in layer blending:Here is the output:
You can create a group to put inside both the polygon and point grid shapefile, so you can turn on/off the layers using the group.
Maybe it is not a perfect solution, but at least this approach will avoid lines intersection inside the group symbology within the same polygon shapefile layer.