user1953401
user1953401

Reputation: 1

Shoelace formula in PostgreSQL

Quite new in SQL world here.

I have a database with coordinates to different places (x,y)

Have followed This guide to convert those coordinates to cartesian coordinates and create a list of ordered coordinates which form a polygon.

With that done, I now face the challenge of calculating the area of said polygon.

To achieve that, the best option seems to be an implementation of the Shoelace Formula. I have found different ways to run the calculation in different languages (see here) and here - page 28, area2d_polygon() function, but have not been successful at all in writing the SQL to perform the same calculation.

PostGIS does not seem to be an option for me here.

Have spent quite a few hours on this one by now. I need to write the SQL that calculates an area in km2 from a list of coordinates that form the polygon.

Any help would be greatly appreciated :)

Upvotes: 0

Views: 80

Answers (0)

Related Questions