I'm trying to figure out how to rotate this satellite geotiff so that the rooftop polygon would appear as square as possible to the viewer rather than a diamond shape. See example below.
How to calculate the angle that the polygon and the image should be rotated to appear squarish? And how to rotate the geotiff by that amount (using gdal say)?
I've tried measuring the angles on the polygon with ST_Dump
and ST_Angle
but that returns nulls. I tried ST_Azimuth which returns values, but I don't understand how to use this information to solve my problem.
Example:
POLYGON((-104.947919 39.530436,-104.948051 39.530497,-104.948127 39.530398,-104.947995 39.530337,-104.947919 39.530436))