[GIS] Point pattern fill with randomly roatetd symbol in QGIS

fillqgissymbology

I'm looking for a way to fill polygon(s) in QGIS with randomly rotated symbols, to reproduce this effect:

enter image description here

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.

enter image description here

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").

enter image description here

Although the preview looks reasonable, the final rendered effect is not:

enter image description here

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.

enter image description here

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:

  1. 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.

enter image description here

  1. Follow your approach to change the marker point symbol into line symbol, and use the formula that you suggested: rand( -180,180) in the expression beside the Angle, and 'Overlay' in layer blending:

enter image description here

Here is the output:

enter image description here

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.