[Qgis-user] geometry generator - unexpected results

Michel Stuyts michel.stuyts at edegem.be
Fri Apr 17 02:50:35 PDT 2020


The numbers you need to use in “rand(-10, 10), rand(-10, 10)” depend on the CRS of your layer. I tested it with some demo data in EPSG:31370 and I got a similar result as you.  When I changed those numbers I got a better result.  After you changed those, you can play around with that 100 inside the generate_series, to get the result you want. For me the following gave a good result:

make_line(
    array_foreach(
        generate_series(
            0, length($geometry), 300
        ),
        translate(
            line_interpolate_point($geometry, @element),
            rand(-0.5, 0.5),
            rand(-0.5, 0.5)
        )
    )
)


Michel

Van: Qgis-user <qgis-user-bounces at lists.osgeo.org> Namens David Fawcett
Verzonden: donderdag 16 april 2020 20:01
Aan: qgis-user <qgis-user at lists.osgeo.org>
Onderwerp: [Qgis-user] geometry generator - unexpected results

I am trying to use a geometry generator to accomplish the "hand-drawn" line style.

Some great recent examples by:

Klas Karlsson
https://twitter.com/klaskarlsson/status/1249333750451879937

Hamish:
https://polemic.nz/2019/11/18/foss4g-qgis-geometry-generators/

I am using the code below from the blog post by Hamish in QGIS 3.12:


make_line(

    array_foreach(

        generate_series(

            0, length($geometry), 100

        ),

        translate(

            line_interpolate_point($geometry, @element),

            rand(-10, 10),

            rand(-10, 10)

        )

    )

)

Here is an image of what the results look like: https://github.com/fawcett/examples/blob/master/lines.png

The line geometries are in blue, and the geometry generator output is in black.

Can anyone suggest what is going wrong?

Thank you,

David.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20200417/53646b60/attachment.html>


More information about the Qgis-user mailing list