2

I want to offset/move the polygons in the direction north-north-western direction and perform this task 3 times. I can do this manually but it would be an approximation and I want them to exactly match. The polygons are 100m long and 5m wide, so it should be moved with 25m three times.

first polygon grid

second polygon offset grid

N_LLC
  • 615
  • 2
  • 8
  • You can move features with the Affine Transform tool. Array of translated features may be easier for your use case, though. – user30184 Apr 26 '23 at 08:05

3 Answers3

6

You can Affine transform twice, with x-axis translation -9.57 (sin(22.5)*25) and y-axis 23.10 (cos(22.5)*25)

enter image description here

BERA
  • 72,339
  • 13
  • 72
  • 161
4

Have a look at the tool array (of) translated features. You may enter how many times you want to copy and move your objects, as well as the distance along X- and Y-axis. The later may require some trigonometry on your part to figure out the exact distance, but an expression as part of data-defined override might help you out there.

Erik
  • 16,269
  • 1
  • 24
  • 43
1

Use the following expression with Geometry Generator or Geometry by expression to shift polygons. Using function project(), you can define distance/angle, thus avoiding trigonometry. Define distance, direction (angle, azimuth) and number of times the polygons should be shifted.

Shift polygons 3 times for 25m (25, 50 and 75 m) in NNW direction (337.5 degrees from north): enter image description here

collect_geometries(
    array_foreach (
        generate_series (1,3),  -- number of times the polygons are shifted
        with_variable(
            'shift',
            @element,
            make_polygon(
                make_line(
                    array_foreach(
                        generate_series (1, num_points($geometry)),
                        project( 
                            point_n(nodes_to_points($geometry), @element),
                            25*@shift,  -- distance to shift the polygons
                            radians(337.5)  -- azimuth (angle)/direction the polygons should be shifted
                        )
                    )
                )
            )
        )
    )
)
Babel
  • 71,072
  • 14
  • 78
  • 208