I am working on a project to transform polygons given in a pre-defined precision to a lesser precision, which I think is equivalent to snap them to a fixed spacing grid.
For example, in the example below, I have a polygon in yellow, I need to snap its vertices to the anchors of a grid (in green). I have tried to load my data to QGIS and use the snap to grid feature, which generates transformed polygon (in cyan). But you can see the transformed polygon has some large distortion, especially in the lower right corner. For this example, I would think the polygon (in red) in the second image is probably a more similar transformed version to the original polygon.
Is there any algorithm that works on this kind of problem, to snap a geometry to grid anchors with minimum distortion? Vertices of the transformed polygon do not need to be the closest to their correspondence on the original polygon. Adding or removing vertices are also allowed, but the resulting shape should be as similar as possible to the original polygon, and the resulting polygon vertices must be on the grid anchors.
I have not found a good metric to measure the similarity, but I am thinking the angle at vertices with two long sides shall be with minimum change. It sounds even like an optimization problem to me.


