Skip to content

Instantly share code, notes, and snippets.

@darrenwiens
Created September 21, 2024 00:51
Show Gist options
  • Save darrenwiens/f00d57f68ee79a1bbccb48c9ebc0849f to your computer and use it in GitHub Desktop.
Save darrenwiens/f00d57f68ee79a1bbccb48c9ebc0849f to your computer and use it in GitHub Desktop.
QGIS Geometry Generator for SimCity Style Bridges
-- add this to a road LINE layer that also has
-- a geometry geometry applied that buffers it
-- by 1000m. That's wide, I know!
-- change the reference to your water layer below.
-- all layers must be in a projected crs.
collect_geometries(
array_foreach(
geometries_to_array(
intersection(
nodes_to_points(
densify_by_distance(
collect_geometries(
array_foreach(
geometries_to_array(
segments_to_lines( $geometry)
),
if(
line_interpolate_angle(@element, 100)>180 AND
line_interpolate_angle(@element, 100)<360,
offset_curve( @element, 1000),
offset_curve( @element, -1000)
)
)
),
2000
)
),
collect_geometries(
overlay_intersects(
layer:= 'ADD_REFERENCE_TO_WATER_LAYER_HERE',
expression:= @geometry
)
)
)
),
make_line(@element, translate(@element, 0, -1000))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment