1

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))

enter image description here

enter image description here

9
  • There is a new function, ST_OrientedBox that could be used to solve this. You need Postgis 2.5. Is this a problem for you? Apr 2, 2019 at 14:41
  • Why? You take the mimimum bounding rectangle and from this you can calculate the rotation against the x or y axis and mimimize this angle with respect to the angles of the image. Why the hell do you think someone who spends hours helping people on Postgis would joke about such a thing? Apr 2, 2019 at 15:34
  • But, anyway, thanks for casting doubt on my abilities and desire to help. It's what keeps us coming back. Apr 2, 2019 at 15:36
  • Peace brother! I googled st_orientedbox and did not find any results. I thought you were trying to tell me that I was asking a preposterously unreasonable question. Apr 2, 2019 at 15:42
  • Comparing bounding rectangle angle to building poly is genius! So simple. Thank you! Apr 2, 2019 at 15:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.