3

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?

enter image description here

1 Answer 1

4

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
 )
)

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.