Skip to main content
2 of 3
edited tags
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Moving polygon feature to be centered on given point using PyQGIS

I am trying to automate a process with inputs of:

  1. Multipart polygon geometry
  2. Four points - which are the actual center points of the four small rectangles within the larger polygon

How can I move the polygon to align with the four points using PyQGIS?

My first attempt was to start with the center points and construct the polygons around them, calculating the orientation of the points and rotating the polygons accordingly, but I'll be receiving different polygons (with varying complexity) and hard-coding the dimensions will be too cumbersome. My next thought is to calculate centroids of those inner rectangles, but then I don't know how to snap them to the actual center points. This is where you all come in.

polygon to overlay on four centerpoints

alaybourn
  • 440
  • 4
  • 11