In QGIS using the Geometry generator, how can we generate the square points within a polygon (e.g. built-up layer) that parallel with other features (e.g. road layer) like in the map below?
1 Answer
Given the layer line
and polygon
, use Geometry generator on the line layer with this expression and style the resulting points with a marker as black squares. What you can adapt:
Line 10 and 19: the number
10
is the interval (distance) along the street where points should be created.Line 15: the number
15
is the lateral distance of the points to both sides from the street.5th last line: replace
polygon
by the name of your polygon layer.
intersection (
collect_geometries(
array_foreach (
array(90,270),
with_variable (
'side',
@element,
collect_geometries (
array_foreach (
generate_series (0, length($geometry), 10),
project (
line_interpolate_point(
$geometry, @element
),
15,
radians (
@side - line_interpolate_angle(
$geometry,
@element/10
)
)
)
)
)
)
)
),
aggregate (
'polygon',
'collect',
$geometry
)
)