7

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?

5
  • Ok, I guess a "proper" random filling is out of question for the moment (hub.qgis.org/issues/3759). So it would seem the workaround is indeed to force larger tiles.
    – jfmoyen
    Jan 24, 2017 at 13:24
  • Try randomising the offset values for the marker. What happens if you randomise the horizontal/vertical distance values for the pattern fill? how about the horizontal/vertical displacement values? Your settings here only randomise the rotation, the points should be appearing in a grid according to this. Jan 24, 2017 at 13:31
  • George: does not work because the distances are randomized only once (per polygon), so you end up with symbol still on a rectangular grid with small tiles, although the grid changes for each pgon.
    – jfmoyen
    Jan 24, 2017 at 13:50
  • Best way to go then would be to create a pattern that has a less obvious tiling, perhaps use svg as you mentioned the original pattern is in illustrator? Although QGIS' implentation may seem like a limitation, I'm not sure if I'd want that approach for millions of strokes across a geometry. As an alternative, have you thought of using the random points generator? Jan 24, 2017 at 15:24
  • Well of course an even more obvious solution is to export the map to illustrator (Corel, inkscape...) and change the pattern there. But this is not really a QGIS question anymore. Random point generator is an idea, but would mean creating a point layer "on top" of the pgons, which is not very neat. Yet, it seems clear that a workaround will be required in the absence of a proper solution.
    – jfmoyen
    Jan 24, 2017 at 16:03

1 Answer 1

3

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.

1
  • Thanks. George of all trades suggested this solution, too, but this is much more detailed (and helpful). I was a bit reluctant to use it, because it involves creating a new layer -- and one that serves only decorative purposes, too. In principle I'd rather keep form and function separated, I believe a GIS layer should be about data, not display. But... this does the trick, of course.
    – jfmoyen
    Jan 27, 2017 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.