Let say I have an irregular polygon layer that I want to divide into squares of fixed size (i.e. 50 x 50m). The simplest solution is to create a grid based on the polygon extension and then use the intersection tool to fit it to the polygon. In such a scenario, the area of the trimmed fields varies considerably, and sometimes a field may be only a few square meters.

I'd like to avoid such a small 'orphans' so I'm looking for a solution, where the area of the smallest field created by clipping the grid to the polygon goes to the maximum.

Moving the grid left or right and testing the size of the smallest field by each test can be quite computationally intensive, but perhaps there is a more pragmatic solution to this problem.

Any ideas?

  • I dont understand "where the area of the smallest field created by clipping the grid to the polygon goes to the maximum."
    – BERA
    Apr 14, 2023 at 5:40
  • 1
    Moving the entire grid causes the clipped fields on the edge of the area to change their size. Thus, the task is to find the optimal grid position, in which the area of the smallest clipped field is maximal (or "goes to the maximum"). With a grid cell size of 100m, it is easy to calculate that there are 10k clipping operations and results to compare if you move the grid within one cell with a step of 1m.
    – flisior
    Apr 14, 2023 at 6:30
  • 1
    I'd be pretty confident that unless your "irregular polygon layer" has some special properties that you haven't mentioned, that there's no real shortcut other than a brute force approach. It's easy to visualise situations where (1) if the grid is shifted in any direction, a small "orphan" will get created, or (2) where if the grid is shifted to remove a small "orphan", a new small orphan will get created. This suggests that any optimiser is unlikely to converge on the best solution. Apr 15, 2023 at 0:37

1 Answer 1


Tesspy might give some inspirations. It provides a sort of ways of tessellation: square, hexagon and voronoi etc.

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.