4

I am currently trying to make a special symbol in QGIS

yellow crossed lines

My best idea is to use Geometry Generator but I can't seem to find any good tutorials besides converting geometry to various types. Is there any way how to draw this in Geometry Generator?

EDIT: I do not need to use the Geometry Generator if there is more suitable way. The catch here is that the symbol needs to be dynamic (depending on the size of the yellow rectangle, the number of yellow crosses will change (from 2 to 6)

4
  • 2
    It's possible to do that with geometry generator. However, the question is what do you need it for and if not a SVG graphic would be better for what you intend to do?
    – Babel
    Aug 12, 2021 at 8:35
  • Hi, thank you for your answer. I have considered SVG but I need this to be dynamic (depending on the size of the yellow rectangle, the numbers of yellow crosses will change). So I am not sure if SVG is the right way... I do not need to use the geometry generator if there will be better solution to my issue.
    – Catallena
    Aug 12, 2021 at 8:55
  • 2
    OK, this is important information that you should include in your question. Please revise it and give a more details about your use case.
    – Babel
    Aug 12, 2021 at 9:09
  • I think as well that using something like svgwrite in python for example is better suited for this than trying to do this in QGIS. Aug 12, 2021 at 9:31

1 Answer 1

4

To create the combined symbology for a point-layer, you can use Geometry generator, combining four symbol layers in this order (from fore- to background):

  1. In the foreground: the 4 yellox X-shaped symbols
  2. The inner, small black polygon
  3. A yellow polygon behind the black polygon from no. 2 and larger than this one to create the yellow frame around the black polygon
  4. Another black polygon behind no. 3 and larger than this one.

See below for the expressions to create these four symbol layers.

The four symbol layers in action - here the expression of the symbol layer on the top (for the X-shapes) is shown: enter image description here

The expressions to create these four symbol layer look as follows (adapt the number to your needs). The first expression to create the X-shape is the most complicated one:

  1. Use this expressions to create the yellow X-shapes. There are a few parameters you can change to adjust the symbols:
  • Value of the variable len in line 3 (here: 1500) to change the length of the lines
  • Value of the variable angle in line 6 (here: 22.5) to change the angle of the X-cross (only change this moderately)
  • line 17, the value of 3700: change this value to change the distance of the for X-shapes from the center of the polygon (move them towards the corner)
with_variable (
    'len',
    1500,
    with_variable (
        'angle',
        22.5,
        collect_geometries (
            array_foreach(
                array (@angle, 180-@angle,180+@angle,360-@angle),
                with_variable (
                    'centroid',
                    centroid (
                        make_line (
                            $geometry,
                            project (
                                $geometry, 
                                3700, 
                                radians(@element)
                    ))),
                    union (
                        extend (
                            make_line (
                                @centroid,
                                project (
                                    @centroid,
                                    @len,
                                    radians (@angle)
                            )),
                            @len,
                            0
                        ),
                        extend (
                            make_line (
                                @centroid,
                                project (
                                    @centroid,
                                    @len,
                                    radians (180-@angle)
                            )),
                            @len,
                            0
)))))))
  1. Change the size of the black polygon in line 3 (here: 4000)
with_variable (
    'distance',
    4000,
    make_rectangle_3points( 
        project ($geometry, @distance, radians(360-22.5)),
        project ($geometry, @distance, radians(22.5)),
        project ($geometry, @distance, radians(180-22.5))))
  1. Change the size of the yellow frame in line 3 (here: 400)
with_variable (
    'distance',
    400,
    make_rectangle_3points( 
        project (project ($geometry, 4000, radians(360-22.5)), @distance, radians (360-45)),
        project (project ($geometry, 4000, radians(22.5)), @distance, radians (45)),
        project (project ($geometry, 4000, radians(180-22.5)), @distance, radians (180-45))))
  1. Change the size of the black frame in line 3 (here: 700)
with_variable (
        'distance',
        700,
        make_rectangle_3points( 
            project (project ($geometry, 4000, radians(360-22.5)), @distance, radians (360-45)),
            project (project ($geometry, 4000, radians(22.5)), @distance, radians (45)),
            project (project ($geometry, 4000, radians(180-22.5)), @distance, radians (180-45))))

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.