[postgis-users] Find out if polygon is circle

Paragon Corporation lr at pcorp.us
Wed Feb 4 20:01:38 PST 2015


>I have many different polygons in my database and would like to know if

there's any way to find out if a polygon has the shape of a circle. I

searched both on Google and in the Postgis documentation but couldn't find

someone with the same question.

 

One thought - use the ST_LineToCurve function and see if it comes back with
a circularstring or one of the curved family of geometry types

A circle would be a circularstring with 3 points

 

http://postgis.net/docs/manual-2.1/ST_LineToCurve.html

 

e.g.

 

SELECT ST_AsText(ST_LineToCurve(ST_Boundary(ST_Buffer(ST_Point(1,2),10))));

 

--

CIRCULARSTRING(11 2,-9 1.99999999999997,11 2)

 

 

 

 

SELECT
ST_GeometryType(ST_LineToCurve(ST_Boundary(ST_Buffer(ST_Point(1,2),10))));

 

ST_CircularString

 

 

If your geometry has any kind of curve, it should come back different

 

So for example

 

SELECT ST_GeometryType(ST_LineToCurve(ST_GeomFromText('LINESTRING(1 2, 3 4,
5 6, 7 8)')))

 

ST_LineString

 

 

Hope that helps,

Regina

http://www.postgis.us

http://postgis.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150204/4561f65d/attachment.html>


More information about the postgis-users mailing list