[postgis-users] get transformation matrix for st_affine using before and after polygons

Darafei "Komяpa" Praliaskouski me at komzpa.net
Sun Jul 29 11:17:47 PDT 2018


Hi,

If polygon is valid and was only translated, scaled and shifted, you can
get the transformation back inspecting first two points of outer ring. For
invalid ones you can do that by finding two non-same points, matching them
in both geometries by number.

If there was some other transformation, like spinning points in rings and
reordering rings, for non-uniform on x and y scaling you will have to go
brute force, trying to match some, preferably longest, edge of outer ring
in first polygon to every edge of outer ring in second.

If scale was uniform, but one polygon was simplified, you can match
endpoints of ST_LongestLine(geom, geom), choosing rotation minimizing
ST_SymDifference area.

On нд, 29 ліп 2018, 19:46 Rhys A.D. Stewart <rhys.stewart at gmail.com> wrote:

> Greetings folks,
>
> Lets say I have two polygons, A and B. These polygons are identical
> (I.E. st_astext(A) = st_astext(B) is true, vertex for vertex clones).
> If I were to move (both translate and rotate)  B somewhere else (using
> QGIS for example) is it possible to generate the transformation
> matrixthat could be used in st_affine to accomplish the same using
> postgis?
>
>
> Regards,
>
> Rhys
> Peace & Love|Live Long & Prosper
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users

-- 
Darafei Praliaskouski
Support me: http://patreon.com/komzpa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20180729/14083518/attachment.html>


More information about the postgis-users mailing list