Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamishcampbell/62d4fd39cc231dfcaf66b5390a12fe35 to your computer and use it in GitHub Desktop.
Save hamishcampbell/62d4fd39cc231dfcaf66b5390a12fe35 to your computer and use it in GitHub Desktop.
QGIS Geometry Generator expression to approximate rock outcroppings
with_variable(
'segment_len',
11, -- the length of each segment
collect_geometries(
array_foreach(
generate_series(
0, length(boundary($geometry)) - @segment_len, @segment_len
),
with_variable('offset_inner',
offset_curve(
make_line(
line_interpolate_point(boundary($geometry), @element),
line_interpolate_point(boundary($geometry), @element + @segment_len)
),
rand(1,11), -- range offset of the inner boundaries
1
),
with_variable('offset_outer',
offset_curve(
make_line(
line_interpolate_point(boundary($geometry), @element),
line_interpolate_point(boundary($geometry), @element + @segment_len)
),
rand(12,30), -- range offset of the outer boundaries
1
),
collect_geometries(
@offset_outer,
make_line(
start_point(@offset_inner),
start_point(@offset_outer)
),
make_line(
end_point(@offset_inner),
end_point(@offset_outer)
)
)
)
)
)
)
)
@JakeOsborneDOC
Copy link

Update: It was my version of QGIS in the end. Upgraded to 3.14 (I wish they'd use leading zeros) and it worked without issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment